没有路由匹配自定义路由

时间:2012-11-28 10:56:29

标签: ruby-on-rails ruby-on-rails-3

我正在为我的用户个人资料配置名为profile.html.erb

的自定义页面

我有一个

No route matches {:action=>"profile", :controller=>"users"}

在路线中,我有:

resources :users do
  member do
    get :profile
  end
end

我的users_controller.rb

def profile
  @user = User.find(params[:id])
  render 'profile'
end

此行发生错误:

<li><%= link_to "Profile", profile_user_path %></li>

我的佣金路线

profile_user GET    /users/:id/profile(.:format)   users#profile

我可以访问profile.html.erb

http://localhost:3000/users/1/profile

1 个答案:

答案 0 :(得分:4)

由于这是会员路线,您需要提供会员。

<li><%= link_to "Profile", profile_user_path(@user) %></li>

刚做

<li><%= link_to "Profile", profile_user_path %></li>在没有给用户的情况下将成为集合的路径。

相关问题