When looking at methods in Rails models, sometimes I see self.method_name and sometimes just a method_name. What’s the difference and what is the guide to know when to use self. and when not to?
When looking at methods in Rails models, sometimes I see self.method_name and sometimes just
Share
self.method_name indicates a class method; method_name indicates an instance method.
You can read a lot more about class and instance methods at this blog post or, if you’d prefer something a bit more official, the Programming Ruby class section.