0

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
      def 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!

Dmitri
  • 2,451
  • 6
  • 35
  • 55

1 Answers1

0

Ah. Nevermind. Solved in myself. Just encapsulate Model.field with proc or lambda.

Dmitri
  • 2,451
  • 6
  • 35
  • 55