views:

26

answers:

2

Hi Everyone,

I have managed to get my email problem sorted so now everytime a case is created an email goes out to the specified address.

I have a usermailer.rb

def makeakase(email, name, jobno, casesubject)
      recipients email
      from "no-reply@your_rails_app.com"
      subject "FW: Kase creation from Survey Manager"
      sent_on Time.now
      body :name => name
  end

and I have the kases_controller.rb:

if @kase.save
          UserMailer.deliver_makeakase("[email protected]", "Highrise")

In the body I would like to use the tags that I use in the kase show view such as:

<%=h @kase.jobno %> - <%=h @kase.casesubject %>

but they don't work, I get the following error:

wrong number of arguments (2 for 4)

Any ideas?

Thanks,

Danny

A: 

Well, your makeakase(email, name, jobno, casesubject) has 4 arguments and you are passing 2:

UserMailer.deliver_makeakase("[email protected]", "Highrise")

And you are not passing @kase to Notifier

You need

  def makeakase(email, name, kase)
      recipients email
      from "no-reply@your_rails_app.com"
      subject "FW: Kase creation from Survey Manager"
      sent_on Time.now
      body :name => name, :kase => kase
  end

UserMailer.deliver_makeakase("[email protected]", "Highrise", @kase)
Voyta
ok, my mistake!How do I show the jobno and casesubject content for the Kase though?UserMailer.deliver_makeakase("XXX.co.uk", "Highrise") ideally the two attributes would be replace by the dynamic content.
dannymcc
You pass `@kase` as third parameter and then use it in the view.
Voyta
A: 

I worked this out:

In the user_mailer view you can put the <%=h @kase.jobno %> - <%=h @kase.casesubject %> tags just like you would in the show view for Kases.

Hope this helps someone else.

Thanks,

Danny

dannymcc