I'm working on building out my mailer, but I keep running into:
wrong number of arguments (0 for 1)
Call my crazy, but I feel like I defined everything correctly:
Controller (truncated for brevity):
def create
@cms484 = Cms484.new(cms484_params)
respond_to do |format|
if @cms484.save
SendLink.message(@cms484).deliver_later
format.html { redirect_to cms484s_path, notice: 'Cms484 was successfully created.' }
format.json { render :show, status: :created, location: @cms484 }
else
format.html { render :new }
format.json { render json: @cms484.errors, status: :unprocessable_entity }
end
end
SendLink.rb:
class SendLink < ApplicationMailer
def message(cms484)
@cms484 = cms484
mail(
:subject => 'Hello from Postmark',
:to => @cms484.recipient ,
:from => 'info@mysite.com',
:html_body => '<strong>Hello</strong> user!.',
end
end
Can anybody else see the needle in the haystack or am I missing something else entirely?
I'm using Postmark for delivery if that matters, and have those parameters defined in my application.rb file as per the documentation. Think this is a simpler matter though.
Edit The complete error:
Completed 500 Internal Server Error in 76ms
ArgumentError (wrong number of arguments (0 for 1)):
app/mailers/send_link.rb:2:in `message'
app/mailers/send_link.rb:4:in `message'
app/controllers/cms484s_controller.rb:38:in `block in create'
app/controllers/cms484s_controller.rb:36:in `create'
Ok, so I decided to re-write it and behold - it works. Why or what's different than the previous version(other than the method email vs mail, surely that can't be it?), I have no idea. If you can see what it is, Please point it out to me!
Send_link.rb:
class SendLink < ApplicationMailer
def email(cms484)
@cms484 = cms484
mail(
:subject => 'Hello from Postmark',
:to => @cms484.recipient ,
:from => 'info@mysite.com',
)
end
end
Controller:
def create
@cms484 = Cms484.new(cms484_params)
respond_to do |format|
if @cms484.save
SendLink.email(@cms484).deliver_later
format.html { redirect_to cms484s_path, notice: 'Cms484 was successfully created.' }
format.json { render :show, status: :created, location: @cms484 }
else
format.html { render :new }
format.json { render json: @cms484.errors, status: :unprocessable_entity }
end
end
end