我对 RoR 很陌生,请帮我确定我错在哪里
我收到以下错误
Routing Error
No route matches {:controller=>"groups"}
Try running rake routes for more information on available routes
尝试渲染以下视图时
<li><%= link_to 'My groups', user_groups_path %></li>
<li><%= link_to 'New group', new_user_group_path %></li>
这是'routes.rb'和rake routes输出
devise_for :users
resources :users do |user|
resources :groups do |group|
resources :people do |person|
end
end
end
new_user_session GET /users/sign_in(.:format) devise/sessions#new
user_session POST /users/sign_in(.:format) devise/sessions#create
destroy_user_session GET /users/sign_out(.:format) devise/sessions#destroy
user_password POST /users/password(.:format) devise/passwords#create
new_user_password GET /users/password/new(.:format) devise/passwords#new
edit_user_password GET /users/password/edit(.:format) devise/passwords#edit
PUT /users/password(.:format) devise/passwords#update
cancel_user_registration GET /users/cancel(.:format) devise/registrations#cancel
user_registration POST /users(.:format) devise/registrations#create
new_user_registration GET /users/sign_up(.:format) devise/registrations#new
edit_user_registration GET /users/edit(.:format) devise/registrations#edit
PUT /users(.:format) devise/registrations#update
DELETE /users(.:format) devise/registrations#destroy
user_group_people GET /users/:user_id/groups/:group_id/people(.:format) people#index
POST /users/:user_id/groups/:group_id/people(.:format) people#create
new_user_group_person GET /users/:user_id/groups/:group_id/people/new(.:format) people#new
edit_user_group_person GET /users/:user_id/groups/:group_id/people/:id/edit(.:format) people#edit
user_group_person GET /users/:user_id/groups/:group_id/people/:id(.:format) people#show
PUT /users/:user_id/groups/:group_id/people/:id(.:format) people#update
DELETE /users/:user_id/groups/:group_id/people/:id(.:format) people#destroy
groups GET /users/:user_id/groups(.:format) groups#index
POST /users/:user_id/groups(.:format) groups#create
new_user_group GET /users/:user_id/groups/new(.:format) groups#new
edit_user_group GET /users/:user_id/groups/:id/edit(.:format) groups#edit
user_group GET /users/:user_id/groups/:id(.:format) groups#show
PUT /users/:user_id/groups/:id(.:format) groups#update
DELETE /users/:user_id/groups/:id(.:format) groups#destroy
users GET /users(.:format) users#index
POST /users(.:format) users#create
new_user GET /users/new(.:format) users#new
edit_user GET /users/:id/edit(.:format) users#edit
user GET /users/:id(.:format) users#show
PUT /users/:id(.:format) users#update
DELETE /users/:id(.:format) users#destroy
这是'model.rb'
class User < ActiveRecord::Base
has_many :groups
class Group < ActiveRecord::Base
belongs_to :user
has_many :people
请帮我弄清楚如何解决这个问题
非常感谢。
UPD
这是解决方案,它有效我进行了@Abibullah 建议的所有更改以及控制器中的两项更改
看法:
<li><%= link_to 'My groups', user_groups_path(current_user) %></li>
<li><%= link_to 'New group', new_user_group_path(current_user) %></li>
路线.rb
resources :users do |user|
resources :groups do |group|
resources :people
end
end
devise_for :用户
GroupsController.rb:
def index
@user = current_user
@user.groups = Group.all
是:def index @user = current_user @groups = Group.all end
用户控制器.rb
class Devise::UsersController < DeviseController
def show
end
end