Reputation: 1130
I have a problem to upgrade my routes.rb file.
I converted this route:
map.resource :index, :controller => "users", :action => "index"
By
resource :index, :to => "users#index"
There is no error raised but the page does not display correctly. Does anyone have an idea?
I have this instruction:
resources :users
Here is my routes.rb file:
JNetExams::Application.routes.draw do |map|
match 'login', :to => 'user_sessions#new', :as => 'login'
match 'logout', :to => 'user_sessions#destroy', :as => 'logout'
root :to => 'user_sessions#new'
resources :groups
resources :students
resources :users
resources :responses
#map.resource :index, :controller => "users", :action => "index"
resource :index, :to => "users#index"
map.resource :account, :controller => "users"
#resource :account, :controller => "users"
resource :user_session
resource :student
resource :user
map.resource :professor, :controller => "professors", :action => "index"
#resource :professor, :to => "professors#index"
map.connect ':controller/:action/:id'
#match ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
#match ':controller/:action/:id.:format'
#map.connect '*url', :controller => :users, :action => :index
match '*url', :to => "users#index"
#map.connect '/user_sessions/show', :controller => "user_sessions", :action => "show"
match '/user_sessions/show', :to => "user_sessions#show"
How can I upgrade this routes file to Rails 3?
Upvotes: 1
Views: 354
Reputation: 6082
resources :index
provides paths for an index resource. So new_index_path
will point to the new
action in the IndexController
. If you do not have an index resource, you should not be using resources to define a path to "users#index"
. This path is already given to you as users_path
through resources :users
. If you are looking to set an index page for your application, you can achieve that using root :to => "users#index"
.
The problem of things not displaying correctly is vague and I employ you to throw more light on that. We are here to help after all.
Upvotes: 2
Reputation: 40770
Do you have a resource called index?
This looks more like it should be
resources :users
If you need more help, please show the whole routes file.
Upvotes: 1