I am pretty new to rails and basically I want to make a user registration form.
I am currently using rails 3.2.3
Basically I want to make basic routes like user/register on top of basic REST route for user.
Here are my routes.rb
resources :user do
collection do
get 'register'
end
end
And here are my rake routes:
register_user_index GET /user/register(.:format) user#register
user_index GET /user(.:format) user#index
POST /user(.:format) user#create
new_user GET /user/new(.:format) user#new
edit_user GET /user/:id/edit(.:format) user#edit
user GET /user/:id(.:format) user#show
PUT /user/:id(.:format) user#update
DELETE /user/:id(.:format) user#destroy
From my understanding, since register user is on top of show, it should match with register first before going to show.
However, when I try to do localhost:3000/user/register, it gives me this error:
No route matches {:action=>”show”, :controller=>”user”}
Can somebody help me with this?
Thanks!!
(I would make this a comment, but I need the markup for the code example.)
I tried your routes using Rails 3.1.4 and it worked like you expected.
I notice you are using a string instead of a symbol. The more standard way is: