I am creating a system that recurring payments each month so I am creating a new payment requirement using the whenever gem
The problem seems to be in my Payment model method, which is here.
class Payment < 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
In the cron.log I was getting a NoMethodError so I tried the method in the rails console and the same error appears:
NoMethodError: undefined method `monthly_payment' for Payment (call 'Payment.connection' to establish a connection):Class
Is there something wrong with the Model?
Here is the schema of Payment:
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