Remove an element from the results after querying. Rails -


let's have database table bananas. can bananas query

@bananas = bananas.all 

now @bananas array of rows in table. now, want remove default primary key 'id' each of element of array. not table @bananas array. how can that??

use select select attributes want retain; not include id in list below remove that.

@bananas = banana.select("size, color") 

edit:

@bananas = banana.select(banana.column_names.reject {|x| x.eql?('id')})


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -