I want to define the class variable test
, threshold
so that I can use Order.test, Order.threshold
in my Rails app
but I can not access the class variable when using the rails console
I must misunderstand something, where's the problem? Thanks.
class Order < ActiveRecord::Base
@@test=123
@@threshold = {
VIP: 500,
PLATINUM: 20000
}
Here is the rails console
irb(main):001:0> Order.class_variables
=> [:@@test, :@@threshold]
irb(main):002:0> Order.test
NoMethodError: private method `test' called for #<Class:0x007fe5a63ac738>
Do this:
Or I'd use constants: