我点击该链接
<%= link_to "(#{User.count_friend_requests(current_user)}) Friends Requests", :controller => "users", :action=>"friend_requests"%>
我得到了那个错误
ActionController::UrlGenerationError in Devise::Registrations#edit
No route matches {:action=>"friend_requests", :controller=>"devise/users", :format=>"1"}
路由
devise_for :users, :path_prefix => 'my'
resources :users, :only => [:friend_requests] do
get "friend_requests", :on => :collection
end
users_controller
def friend_requests
@frnds = User.find_friend_requests(current_user)
end
答案 0 :(得分:1)
嘿,你已经使用前缀/my/
装载了设计,所以你的路线就像
/my/users/..
和resources :users
安装代码时没有任何前缀。
您应该删除前缀my
或者将resources
更改为
scope "my" do
resources :users, :only => [:friend_requests] do
get "friend_requests", :on => :collection
end
end
获取/my/users/friend_requests/
此外,我看到rails在设计/用户(不在您的用户中)控制器中查找您的方法
No route matches {:action=>"friend_requests", :controller=>"devise/users", :format=>"1"}
如果你想修补它,你应该看看如何修补设备的用户控制器。