我的项目出了点奇怪的问题。我有Rails 3,Devise已经启动并运行,我添加了自定义路由:
match '/users', :to => 'users#index', :as => "all_users", :via => "get"我的rake路径返回以下内容:
marat@rails:~/projects/test$ rake routes | grep users
new_user_session GET /users/sign_in(.:format) {:action=>"new", :controller=>"devise/sessions"}
user_session POST /users/sign_in(.:format) {:action=>"create", :controller=>"devise/sessions"}
destroy_user_session GET /users/sign_out(.:format) {:action=>"destroy", :controller=>"devise/sessions"}
user_password POST /users/password(.:format) {:action=>"create", :controller=>"devise/passwords"}
new_user_password GET /users/password/new(.:format) {:action=>"new", :controller=>"devise/passwords"}
edit_user_password GET /users/password/edit(.:format) {:action=>"edit", :controller=>"devise/passwords"}
PUT /users/password(.:format) {:action=>"update", :controller=>"devise/passwords"}
user_registration POST /users(.:format) {:action=>"create", :controller=>"devise/registrations"}
new_user_registration GET /users/sign_up(.:format) {:action=>"new", :controller=>"devise/registrations"}
edit_user_registration GET /users/edit(.:format) {:action=>"edit", :controller=>"devise/registrations"}
PUT /users(.:format) {:action=>"update", :controller=>"devise/registrations"}
DELETE /users(.:format) {:action=>"destroy", :controller=>"devise/registrations"}
user_confirmation POST /users/confirmation(.:format) {:action=>"create", :controller=>"devise/confirmations"}
new_user_confirmation GET /users/confirmation/new(.:format) {:action=>"new", :controller=>"devise/confirmations"}
GET /users/confirmation(.:format) {:action=>"show", :controller=>"devise/confirmations"}
user_unlock POST /users/unlock(.:format) {:action=>"create", :controller=>"devise/unlocks"}
new_user_unlock GET /users/unlock/new(.:format) {:action=>"new", :controller=>"devise/unlocks"}
GET /users/unlock(.:format) {:action=>"show", :controller=>"devise/unlocks"}
user_comments GET /users/:user_id/comments(.:format) {:action=>"index", :controller=>"comments"}
POST /users/:user_id/comments(.:format) {:action=>"create", :controller=>"comments"}
new_user_comment GET /users/:user_id/comments/new(.:format) {:action=>"new", :controller=>"comments"}
edit_user_comment GET /users/:user_id/comments/:id/edit(.:format) {:action=>"edit", :controller=>"comments"}
user_comment GET /users/:user_id/comments/:id(.:format) {:action=>"show", :controller=>"comments"}
PUT /users/:user_id/comments/:id(.:format) {:action=>"update", :controller=>"comments"}
DELETE /users/:user_id/comments/:id(.:format) {:action=>"destroy", :controller=>"comments"}
users GET /users(.:format) {:action=>"index", :controller=>"users"}
POST /users(.:format) {:action=>"create", :controller=>"users"}
new_user GET /users/new(.:format) {:action=>"new", :controller=>"users"}
edit_user GET /users/:id/edit(.:format) {:action=>"edit", :controller=>"users"}
user GET /users/:id(.:format) {:action=>"show", :controller=>"users"}
PUT /users/:id(.:format) {:action=>"update", :controller=>"users"}
DELETE /users/:id(.:format) {:action=>"destroy", :controller=>"users"}
all_users GET /users(.:format) {:controller=>"users", :action=>"index"}我的控制器:
class UsersController::SessionsController < Devise::SessionsController我得到了一个错误:
Expected /home/marat/projects/brandbk/app/controllers/users_controller.rb to define UsersController我哪里做错了?例如,我如何添加索引操作来设计控制器以显示所有用户。谢谢。
发布于 2011-02-18 03:53:40
将您的控制器更改为:
class UsersController < ApplicationController您当前定义的是SessionsController而不是UsersController。
https://stackoverflow.com/questions/5033152
复制相似问题