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
Post a Comment