Ruby rails - select only few columns from the data base
Rails 3:
Item.select("name, address").where( .... )
Make use of :select
construct. Try this:
@itemlist = Item.select('name, address', conditions: { .... } )
For previous version of Rails:
@itemlist = Item.find(:all,:select => 'name, address', :conditions => { .... } )
Using Arel (aka in Rails 3), use:
Item.where(...).select("name, address")
Also, it seems .select gets ignored if you tack on a scope that has an :include => ...