0

I want to be able to call Activity.pull_latest from a controller, but if I do

class Activity < ActiveRecord::Base
  def pull_latest [...]

I have to call it Activity.new.pull_latest.

How do I define in the model a class method, not an instance one?

Marius Butuc
  • 17,781
  • 22
  • 77
  • 111

1 Answers1

2

Use self:

def self.pull_latest

Then you can call Activity.pull_latest

Dylan Markow
  • 123,080
  • 26
  • 284
  • 201