Ruby on rails 如何显示带有链接到rails的配置文件

Ruby on rails 如何显示带有链接到rails的配置文件,ruby-on-rails,email,url,dynamic,hyperlink,Ruby On Rails,Email,Url,Dynamic,Hyperlink,最后,我们为邮件生成了一个有用的链接。 这个很好,很好。但我们想称之为鞋子行动:-) 我们需要这种结构 http://localhost:3000/mycontroller/10 rake routes命令这样说 mycontroller GET /mycontroller/:id(.:format) mycontroller#show 我们如何获得所需的结构?我们是否需要编辑路由,或者是否有其他方法获得正确的url?尝试使用路由帮助器 mycontro

最后,我们为邮件生成了一个有用的链接。 这个很好,很好。但我们想称之为鞋子行动:-)

我们需要这种结构

http://localhost:3000/mycontroller/10
rake routes
命令这样说

mycontroller GET    /mycontroller/:id(.:format)               mycontroller#show

我们如何获得所需的结构?我们是否需要编辑路由,或者是否有其他方法获得正确的url?

尝试使用路由帮助器

  mycontroller_url(@mycontroller.id)
相反,{:controller=>…,:action=>…}

您到帮助器的链接应该如下所示,以便更好地使用“用户显示”操作

rake路由返回这个

user GET  /users/:id(.:format) users#show
现在我知道我可以使用user_url(@user)助手了



这可以工作,但还有一个错误。
:仅_path=>false
将不被接受。url看起来是这样的
mycontroller/:id
没错,但没有主机。一个不是最好的解决方案是构建url而不是链接
'show',:controller=>'wishlists',:only_path=>false,:id=>@wishlist.id)%%>
好的,您可能应该在邮件设置或邮件中设置主机,因为我们不需要链接,我们需要URL:-)谢谢您。晚安您的
routes.rb
文件现在看起来怎么样?你能把它贴在这里吗?
  mycontroller_url(@mycontroller.id)
user GET  /users/:id(.:format) users#show
<%=link_to('Link', user_url(@user) )%>