Rails route.rb 设置的 url 问题

asmcos · February 19, 2013 · Last by asmcos replied at February 19, 2013 · 2138 hits

route.rb 配置

get "/members/:name/edit" => "users#edit"

views 里面 改如何写? 下面下法总报错。

<%= link_to "edit profile", edit_member_path(@user.name) %>

加个 :as 参数给它命个名。

get "/members/:name/edit",  :to => "users#edit",  :as => :edit

谢谢 @lshgood 问题解决了:

在 views 里面可以这么用:

<%= link_to "edit profile", edit_members_path(@user.name) %>

You need to Sign in before reply, if you don't have an account, please Sign up first.