0

users_controller.rb我有我的方法:

def showallusers
 @users = User.all

 respond_to do |format|
  format.html  # showallusers.html.erb
  format.json  { render :json => @users }
 end
end

app/views/users我有showallusers.html.erb并在其中:

<p>test</p>

但是当我输入

 http://localhost:3000/users/showallusers

在浏览器中,它向我显示show.html.erb

我的路线.rb

  resources :users

  resources :projects do
    resources :issues  
  end

  #resources :issues

  resources :projects

  resources :sessions


  root :to => "users#index"

  match "/auth/:provider/callback" => "sessions#create"
  match "/signout" => "sessions#destroy", :as => :signout

你知道,出了什么问题,我该如何解决?谢谢

4

1 回答 1

1

在您的 routes.rb 中:

resources :users do
  collection do
    get :showallusers # why not :show_all_users? Isn't it more readable?
    # you may also need
    # post :showallusers
  end
end

然后重新启动服务器以确保生成了新的 url-helper(新的 helper 应该是showallusers_users_path

于 2013-02-27T21:46:03.130 回答