Ruby on Rails with_option cannot call class method
- by Dmitri
I have a problem calling class method from the with_option block with validations:
Model:
class Model < ActiveRecord::Base
attr_accessible :field
with_options :if => "<not important>" do |step|
... bunch of validations
step.validates :field, :inclusion => {:within => Model.field}
end
private
self.field
(1..10)
end
end
And it returns: undefined method `field' for #Class:0x5f394a8
self.class.field also doesn't work.
What is wrong with it ? How to fix it ?
Big big thanks!