title: 'NoMethodError: undefined method' in Ruby on Rails Model
body: <p>I am creating a system that recurring payments each month so I am creating a new payment requirement using the <strong>whenever gem</strong></p>
  
  <p>The problem seems to be in my Payment model method, which is here.</p>
  
  <pre><code>class Payment &lt; ActiveRecord::Base
    belongs_to :client
  
    def monthly_payment
      clients = Client.all
      clients.each do |client|
        Payment.create(month: Date.now, client_id: client.id)
      end
    end
  end
  </code></pre>
  
  <p>In the cron.log I was getting a NoMethodError so I tried the method in the rails console and the same error appears:</p>
  
  <pre><code>NoMethodError: undefined method `monthly_payment' for Payment (call 'Payment.connection' to establish a connection):Class
  </code></pre>
  
  <p>Is there something wrong with the Model?</p>
  
  <p>Here is the schema of Payment:</p>
  
  <pre><code>create_table "payments", force: :cascade do |t|
   t.date     "date"
   t.string   "type"
   t.date     "month"
   t.boolean  "paid"
   t.datetime "created_at", null: false
   t.datetime "updated_at", null: false
   t.integer  "client_id"
  end
  </code></pre>