J
Jean Nibee
How come this works when I access Orders:
AYMENT_TYPES
class Order < ActiveRecord::Base
PAYMENT_TYPES = [
[ "Check", "check" ],
[ "Credit card", "cc" ],
[ "Purchase order", "po" ]
]
has_many :line_items
validates_presence_of :name, :address, :email,
ay_type
validates_inclusion_of
ay_type, :in => PAYMENT_TYPES.map {|disp,
value| value}
end
<<<<<<<<<< CODE
But this doesn't:
class Order < ActiveRecord::Base
has_many :line_items
validates_presence_of :name, :address, :email,
ay_type
validates_inclusion_of
ay_type, :in => PAYMENT_TYPES.map {|disp,
value| value}
PAYMENT_TYPES = [
[ "Check", "check" ],
[ "Credit card", "cc" ],
[ "Purchase order", "po" ]
]
end
<<<<<<<<<< CODE
Error thrown:
/usr/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:477:in
`const_missing'
I have moved the PAYMENT_TYPES map around and it even is okay if it's
after the has_many :item_lines accessor, but not if it's after the
'validation' accessors.
Thanks.
class Order < ActiveRecord::Base
PAYMENT_TYPES = [
[ "Check", "check" ],
[ "Credit card", "cc" ],
[ "Purchase order", "po" ]
]
has_many :line_items
validates_presence_of :name, :address, :email,
validates_inclusion_of
value| value}
end
<<<<<<<<<< CODE
But this doesn't:
class Order < ActiveRecord::Base
has_many :line_items
validates_presence_of :name, :address, :email,
validates_inclusion_of
value| value}
PAYMENT_TYPES = [
[ "Check", "check" ],
[ "Credit card", "cc" ],
[ "Purchase order", "po" ]
]
end
<<<<<<<<<< CODE
Error thrown:
/usr/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:477:in
`const_missing'
I have moved the PAYMENT_TYPES map around and it even is okay if it's
after the has_many :item_lines accessor, but not if it's after the
'validation' accessors.
Thanks.