Hi, I'm begining with rails I need to get an array of all id of a table.
name of my model is ContentGroup so I tried ContentGroup.find(:all, :order=>"ASC") but I have an array of objet and I only need the ids.
How can I do to get only id fields ?
Hi, I'm begining with rails I need to get an array of all id of a table.
name of my model is ContentGroup so I tried ContentGroup.find(:all, :order=>"ASC") but I have an array of objet and I only need the ids.
How can I do to get only id fields ?
Hi, I'm begining with rails I need to get an array of all id of a table.
name of my model is ContentGroup so I tried ContentGroup.find(:all, :order=>"ASC") but I have an array of objet and I only need the ids.
How can I do to get only id fields ?
ContentGroup.find(:all, :order=>"ASC").collect {|cg| cg.id}
David Nguyen wrote:
Hi, I'm begining with rails I need to get an array of all id of a table.
name of my model is ContentGroup so I tried ContentGroup.find(:all, :order=>"ASC") but I have an array of objet and I only need the ids.
How can I do to get only id fields ?
Hi Try this @user=ContentGroup.find(:all,:select=>"id",:order=>"id asc")
David Nguyen wrote:
Hi, I'm begining with rails I need to get an array of all id of a table.
name of my model is ContentGroup so I tried ContentGroup.find(:all, :order=>"ASC") but I have an array of objet and I only need the ids.
How can I do to get only id fields ?
ContentGroup.find(:all, :select => 'id').map(&:id)