I was wondering if it’s possible to pass in a parameter to methods when you’re using the :if option with the ‘with_options’ method.
For example, can I call something like this?
with_options :if => :is_user_this_level?(threshold_level) do |some_object|
some_object.validates_with ObjectValidator
end
I’m wondering if it’s possible to pass in the variable ‘threshold_level’ to the :if option method. Basically I want to do this because I don’t want to have methods like :is_user_level_two?, :is_user_level_three? and so on and so forth.
Also if there’s a RAILS way of doing this and I’m barking up the wrong tree please let me know.
Thanks!
The usual
:ifoption for ActiveRecord callbacks can take a lambda as its argument so maybe this will work: