Hello.
I would like to know if it is possible to call a method from a model after using find.
Something like after_save
, but after_find
.
Thank you, Gabriel.
Hello.
I would like to know if it is possible to call a method from a model after using find.
Something like after_save
, but after_find
.
Thank you, Gabriel.
There is. Along with after_initialize
, after_find
is a special case, though. You have to define the method, after_find :some_method
isn't enough. This should work, though:
class Post < ActiveRecord::Base
def after_find
# do something here
end
end
You can read more about it in the API.