私はグループとサブグループでユーザーを分割し、各サブグループにカスタマイズされたサイトを提供するRailsアプリケーションを作成しようとしています。私はそれを行うための最も簡単な方法は、名前付きパラメータでスコープを作成することでした考え出し:それは完璧に動作Rails 3:名前付きパラメータのルートbreak link_to
users GET /:group/:subgroup/users(.:format) {:action=>"index", :controller=>"users"}
POST /:group/:subgroup/users(.:format) {:action=>"create", :controller=>"users"}
new_user GET /:group/:subgroup/users/new(.:format) {:action=>"new", :controller=>"users"}
edit_user GET /:group/:subgroup/users/:id/edit(.:format) {:action=>"edit", :controller=>"users"}
user GET /:group/:subgroup/users/:id(.:format) {:action=>"show", :controller=>"users"}
PUT /:group/:subgroup/users/:id(.:format) {:action=>"update", :controller=>"users"}
DELETE /:group/:subgroup/users/:id(.:format) {:action=>"destroy", :controller=>"users"}
- 私はのlink_toを使用するときを除い:
scope ":group/:subgroup/" do
devise_for :users
resources :users
end
「すくいルート」そして、これを生成します。
link_to current_user.name, current_user
そして、それは
ActionController::RoutingError in Users#index
Showing C:/Rails/MyApp/app/views/users/_my_list.html.haml where line #8 raised:
No route matches {:action=>"show", :controller=>"users", :group=>#<User id: 7, email: "[email protected]", encrypted_password: "$2a$10$GdZeC0b4VaNxdsDXP...", password_salt: "$2a$sj$88gm0nttYE.7a4IHi.BNO", reset_password_token: nil, remember_token: nil, remember_created_at: nil, sign_in_count: 86, current_sign_in_at: "2011-08-05 17:18:19", last_sign_in_at: "2011-08-05 00:14:26", current_sign_in_ip: "127.0.0.1", last_sign_in_ip: "127.0.0.1", confirmation_token: nil, confirmed_at: "2010-12-09 23:08:54", confirmation_sent_at: "2010-12-09 23:08:36", failed_attempts: 0, unlock_token: nil, locked_at: nil, created_at: "2010-12-09 23:08:36", updated_at: "2011-08-05 17:18:19", name: "UserOne">}
このエラーがスローされます
行#8はもちろん、私がlink_toを使用しようとしたところです。私の推測では、link_toはスコープを無視しています。これはcurrent_userが:groupパラメーターに詰め込まれていることを説明しています。これが起こらないようにする方法はありますか、それとも私はこの問題全体について全く間違っていますか?