我有一个链接,点击后,应该使用控制器中定义的操作发送电子邮件。我没有正确设置路径:
= 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
我收到以下错误消息No route matches {:action=>"deliver_customer_mailer", :controller=>"quotes"}
。 A)创建该链接的正确方法是什么。 B)我有更好的方法来构建这个吗?感谢。
啊,我需要将一个值传递给路径... quote_deliver_customer_mailer_path(quote)
答案 0 :(得分:0)
您必须在控制器中创建方法,然后设置路由到它,并从控制器发送电子邮件。你不能从视野中去做。