before_validation issues with rails -


the problem using

def before_validation   self.author.strip!   self.author_email.strip! end 

and error message:

deprecation warning: base#before_validation has been deprecated, please use base.before_validation :method instead.

can point me in right direction. thanks

somewhere toward top of class model place name of clean-up method:

before_validation :remove_whitespace 

... , further down model class place private method same name:

def remove_whitespace   self.author.strip!   self.author_email.strip! end 

optionally, if want one-liner, pass lambda instead of method name before_validation:

before_validation lambda {self.author.strip!; self.author_email.strip!} 

Comments

Popular posts from this blog

php - How to build a web site which gives a sub-domain dynamically to every registered user? -

c# - Add item to Generic List / Collection using reflection -