Get back routes the old way

How do I regain freedom in Rails 3 so I can add what ever actions I want with as little hassle as possible? Is there a way to do this instead of having to declare it per action.

Have a look at the Rails Guide on routing. You have not really explained what you are trying to do but I am guessing that section 3.1 may be what you want.

Colin

Colin Law wrote in post #969281:

Have a look at the Rails Guide on routing. You have not really explained what you are trying to do but I am guessing that section 3.1 may be what you want.

Colin

I would like to be able to add any action I want. If I add a resources :test and have a controller called test and an action test I get "The action 'show' could not be found for TestController"

Paul Bergstrom wrote in post #969317:

Colin Law wrote in post #969281:

Have a look at the Rails Guide on routing. You have not really explained what you are trying to do but I am guessing that section 3.1 may be what you want.

Colin

I would like to be able to add any action I want. If I add a resources :test and have a controller called test and an action test I get "The action 'show' could not be found for TestController"

Is test a reserved word in Rails 3?

Best,

Marnen Laibow-Koser wrote in post #969319:

Paul Bergstrom wrote in post #969317:

Is test a reserved word in Rails 3?

?

How do I deal with a page called "overview" that displays information from many models at the same time?

How do I deal with a page called "me" that displays information about the user? I can see the benefit of routes in a basic database app with list, view, edit, show. But I don't understand the logic for examples like mine. In my case it will make much more sense for the user to go to a page called "me" than "user/2".

# routes.rb   map.me 'me', :controller => 'users', :action => 'display_current_user'

  # UsersController   def display_current_user     @user = current_user # assuming you do have a current_user method     ... [rest of action code]   end

...which gives you access to "me_path" and all the other routes helping malarkey.

http://api.rubyonrails.org/classes/ActionDispatch/Routing.html

How do I deal with a page called "overview" that displays information from many models at the same time?

There does not have to be one to one relationship between controllers and models. A controller can get data from as many models as it likes. You could have an overview controller if that seems appropriate. If the data from the various models is displayed on different areas of the screen then use a partial for each section.

How do I deal with a page called "me" that displays information about the user? I can see the benefit of routes in a basic database app with list, view, edit, show. But I don't understand the logic for examples like mine. In my case it will make much more sense for the user to go to a page called "me" than "user/2".

What do you mean 'a page called me'? Do you mean the URL? If so how would you know which user to show for that url?

Colin

Colin Law wrote in post #969381:

What do you mean 'a page called me'? Do you mean the URL? If so how would you know which user to show for that url?

Yes. The url. From the session id.

Does Michael's post answer that one?

Colin

strange, what you are asking is easier in rails 3 than 2.

http://railscasts.com/episodes/203-routing-in-rails-3

Michael Pavling wrote in post #969380: e called "me" than "user/2".

  # routes.rb   map.me 'me', :controller => 'users', :action => 'display_current_user'

Should't that be match?

I wrote it off the top of my head, so you could be right. But it also depends what version of Rails the OP has to what routing commands he can use... but the general gist is that he should be able to achieve what he wants with routes...

I added this:

match ':controller(/:action(/:id(.:format)))'

and it did the trick. I think.