jon wrote:
Hi,
Is it possible to call a functon using callbacks, passing a number of attr_names in? i.e. somthing like this
before_save :tst => :title, :content
def test(*attr_names) attr_names.each do |record, attr_name, value|
end end
Two questions.
1) Are you trying to create a custom validation in your model? This wouldn't be the route to take.
I'm going to guess that this is the case.
You'd want to extend AR to build your own validation method.
-- or --
2) Do you just need a custom before_save method to be called?
If this, then I'm not sure why you'd need to pass an arbitrary set of methods into the function.
before_save :test
def test [:attr_1, :attr_2].each...
end
Good luck!
Robby