I want to do something like this:
validates_presence_of :name, :message => custom_message
def custom_message
"Custom Message"
end
But when I try it I get "undefined local variable or method for custom method"
Whats up with that?
I want to do something like this:
validates_presence_of :name, :message => custom_message
def custom_message
"Custom Message"
end
But when I try it I get "undefined local variable or method for custom method"
Whats up with that?
try this ,, if im not wrong
before_save :custom_message def custom_message self.custom_message = "Custom Message" if published == true end end
Have you tried putting the definition of custom_message before the validates_presence_of line? validates_presence_of is a class method, and when it is evaluated Ruby has not yet seen the definition below it.
Think I figured it out. If you use a symbol instead of the method directly.
e.g :message => :custom_message