ror directory wrote:> Hi
> I want to create send emails to users as soon as a product is created;
>
> So I created scaffold for Product and before as soon as I do the save I
> call my send_email method in another controller; Now I want to pass on
> the Product record we created. I tried sending the product as @product,
> :product,etc. (tried all) and none work; my idea is to get the product
> record and put it in the email template like:-
>
> "Dear Customer. <%= product.name %> has arrived at our warehouse
and
> ready for pick up....."
>
> thanks
In your send_mail method in whatever your mailer model is, you need to
change the definition of
send_mail(sent_at = Time.now)
to
send_mail(product, sent_at = Time.now)
and then in the body of that method,
@body = {:product => product}
That will get you @product in the .rhtml file for send_mail.
--
Posted via http://www.ruby-forum.com/.