routes.rb don’t require restart
Just noticed that changes to routes.rb doesn’t require Rails application restart anymore (I’m on Rails 2.0.1). Cool stuff!
So now we can introduce another named route like this:
map.cloud 'projects/cloud', :controller => 'projects', :action => 'cloud'
and then immediately use cloud_url in templates.
Why I wanted to use named route for such a simple case? Actually not because it gives nice ‘cloud_url’ shortcut. I currently use it in a single place so it dosn’t matter to me. The reason is that my ‘projects’ controller is REST-friendly, i.e. I have ‘map.resources :projects’ in routes.rb. So, I have to add some line to routes.rb to use /projects/cloud – otherwise Rails thinks ‘cloud’ is an Id of project I’m trying to open. So I have 2 options, named route and map.connect, and now the choise is obvious.
Filed under: rails, tips | 2 Comments
Search
-
You are currently browsing the Artem Vasiliev's Weblog weblog archives.
What about
map.resources :projects do |project|
project.resources :cloud
end
This stuff or something like that?
Yeah, great option, thanks Dzso!