I have a link that, when clicked, should deliver an email by using an action defined in a controller. I am not setting the path correctly however:
= link_to "Email", quote_deliver_customer_mailer_path
quotes_controller
def deliver_customer_mailer(quote)
@quote = quote
CustomerMailer.estimate(@quote).deliver
end
routes.rb
resources :quotes do
get :deliver_customer_mailer
end
I get the following error message No route matches {:action=>"deliver_customer_mailer", :controller=>"quotes"}. A) What would be the right way to create that link. B) Is there a better way I should be building this? Thanks.
Update
Ah, I needed to pass a value into the path… quote_deliver_customer_mailer_path(quote)
You must create a method in controller then set route to it and from controller send an email. You can’t do it from view.