Ruby on Rails : add a new route

ruby, ruby-on-rails

Solution

This doesn't work automatically in rails 3. You'll need to add

resource :users do
    get "foo"
end

to your routes.rb

You'll definitely want to have a look at http://guides.rubyonrails.org/routing.html, it explains routing pretty well.

Problem

I'm new with RoR so this is a newbie question: if I have a controller `users_controller.rb` and I add a method `foo`, shouldn't it create this route? http://www.localhost:3000/users/foo because when I did that, I got this error: Couldn't find User with id=foo I of course added a view `foo.html.erb` EDIT: I added to `routes.rb` this code but I get the same error: ``` resources :users do get "signup" end ```

Original source