首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Rails 3设计问题

Rails 3设计问题
EN

Stack Overflow用户
提问于 2011-02-18 02:44:25
回答 1查看 2K关注 0票数 0

我的项目出了点奇怪的问题。我有Rails 3,Devise已经启动并运行,我添加了自定义路由:

代码语言:javascript
复制
match '/users', :to => 'users#index', :as => "all_users", :via => "get"

我的rake路径返回以下内容:

代码语言:javascript
复制
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"}

我的控制器:

代码语言:javascript
复制
class UsersController::SessionsController < Devise::SessionsController

我得到了一个错误:

代码语言:javascript
复制
Expected /home/marat/projects/brandbk/app/controllers/users_controller.rb to define UsersController

我哪里做错了?例如,我如何添加索引操作来设计控制器以显示所有用户。谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-02-18 03:53:40

将您的控制器更改为:

代码语言:javascript
复制
class UsersController < ApplicationController

您当前定义的是SessionsController而不是UsersController。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5033152

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档