-1

在邮件视图中:

      <%= url_for(controller:'resas', action: 'show', only_path: false) %>

耙路线:

                      resa GET    /resas/:id(.:format)             resas#show

这是尝试生成电子邮件时的异常:

No route matches {:action=>"show", :controller=>"resas"}

我的主机是参数化的(作为本地主机)。

4

2 回答 2

2

我认为您需要为显示路线传递一个ID。尝试

<%= url_for(controller:'resas', action: 'show', id: @resa.id, only_path: false) %>

(不确定您的资源是如何命名的)

于 2014-07-19T15:19:34.287 回答
0

至少您的路线语法不正确。尝试:

#routes.rb
GET    /resas/:id(.:format), to: resas#show

在此处阅读 rails 文档中有关路由和路由语法的所有信息:http: //guides.rubyonrails.org/routing.html

看起来您可能想在only_path: false不提供主机名的情况下重新考虑。在此处阅读有关 url_for 和 only_path 的更多信息:http: //api.rubyonrails.org/classes/ActionDispatch/Routing/UrlFor.html

于 2014-07-19T15:05:47.543 回答