Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extending Rails models

Rails models come with certain built-in methods like this:

Appointment.new
Appointment.find(1)

How do I add more methods to Appointment? It's apparently not done by adding methods to app/models/appointment.rb. Doing that adds methods to an instance of Appointment, but I want to add methods to Appointment itself. How do I do that?

like image 634
Jason Swett Avatar asked Dec 08 '22 00:12

Jason Swett


1 Answers

def self.some_method
  #do stuff
end
like image 142
mark Avatar answered Dec 23 '22 13:12

mark