How to pass params into a model callback method in rails?
I have an 'after_update' callback method in my model:
after_update :reprocess_image
and I want to pass the params[:member] I collected from my开发者_运维知识库 edit form into this reprocess_image method after updating.
How do I do that?
I would prefer to do this at the instance level. You can use a virtual attribute:
attr_accessor :member
I'm not an experienced railer, but I think it would work if you simply use a property of your model to store this value.
something like:
my_class.member = 'a-member'
class MyClass
after_update :reprocess_image
def reprocess_image
do_something_with_your self.member
end
end
精彩评论