Not getting a [:id] parameter from url, Default route is not working
When I request a URL as follows:
I'm not getting the [:id] parameter, i.e. 4RghIKJNygEDswIuuCo.
Here is my route file, are there any modifications required for this?
ActionController::Routing::Routes.draw do |map| match 'primary', :to => 'pages#primary', :as => "primary" match 'admins', :to => 'admin_users#list', :as => "admins" match 'login', :to => 'user_sessions#new', :as => "login" match 'logout', :to => 'user_sessions#destroy', :as => "logout" root :to =>"public#index" match 'HFA/:id/' => 'public#show' match 'HFA/:id/:uid' =>'public#show' match 'public/projectview/:projectid/' => 'public#projectview' map.connect ':controller/:action/:id.:format' map.connect ':controller/:action/:id' resources :users resources :usertypes resources :user_sessions end
The default is /controller/:id/edit, following the REST architecture.
Do you really want to change this?
If so, verify the order of the declarations:
Rails routes are matched in the order they are specified, so if you have a resources :photos above a get 'photos/poll' the show action’s route for the resources line will be matched before the get line. To fix this, move the get line above the resources line so that it is matched first.
and check your availables routes with the rake routes command:
if you put match instead of 'get' you will get all http (GET, POST, PUT, DELETE) route verbs
get 'password_resets/:id/edit', to: 'password_reset#create', as: :send_password_reset
the 'to:' defines the controller method, 'as:' defines the path name, 'get' defines the route verb and ':id' is the token created by this line in app/views/user_mailer/password_reset.text.erb
<%= send_password_reset_url(@user.password_reset_token) %>
run "rake routes" command and check the routes for "password_resets/edit/4RghIKJNygEDswIuuCo".