how can I write my own validation helper method that can be reused in several different models
I want to write one common validation helper metho开发者_开发问答d that can be used in different models e.g.
def validate_my_own_column(arg1, arg2)
{
if arg1 > arg2
...
else
...
end
}
I want to call validate_my_own_column(arg1, arg2) method in various models. how can I achieve this?
Thanks
You tagged this question ruby-on-rails-2. Unfortunately what you want is somewhat complicated to do in Rails 2. If you are in fact using Rails 3, it's simple: take a look at http://api.rubyonrails.org/classes/ActiveModel/Validator.html.
精彩评论