Coda Chang Coda Chang - 7 months ago 15
Ruby Question

Rails ActiveRecord select usage

I've been confused for a while, I follow the rails doc, and it say"viewable_by, locked")
will only select only a subset of fields.

Now I got a model call

class Goods < ActiveRecord::Base {
:id => :integer,
:name => :string,
:translate_key => :string,
:created_at => :datetime,
:updated_at => :datetime,
:discount_json => :text,
:price_mapping => :text,
:goods_type => :string,
:reference_id => :integer,
:available => :boolean

When I try
, it works fine.
However, when I did,:translate_key)

It threw
ArgumentError: wrong number of arguments (2 for 0..1)


If you want to pass multiple columns pass them in an array[:name, :translate_key])

This way you can still use symbols

Active record select