Suppose I have a Post model and I’d like to run a method when it’s saved
in post.rb I do:
:before_save some_method_on_post
def some_method_on_post
# Do something here
end
My question is, how do I refer to the current instantiated Post object inside of the method?
Edit: so to clarify suppose I wanted to do this:
def some_method_on_post
post.some_property = foo
end
Do I refer to post as self?
When using an attribute setting method, you refer to
selfas in methodAs a shortcut convenience, when you have a method that retrieves but does not set the object (so a getter), you can omit the
self, e.g.