Hey,

comments inline:

On 28-Dec-06, at 9:34 AM, Rick Olson wrote:


On 12/20/06, Trevor Squires <[EMAIL PROTECTED]> wrote:

Hi,

in my current project I've got a couple of map.resources as such:

map.resources :quote_requests do |quote_request|
   quote_request.resources :request_items
end

map.resources :quotes, :controller => 'quote_requests'

Or just call the controller QuotesController instead of
QuoteRequestsController.  Is this really so bad?  I'd think having the
shorter url and routes would be a plus.


Rick, you're absolutely right insofar as there's more than one way to skin this cat.

However, your suggestion to use the controller as a way to make the URL opaque will still leave the URL helpers as quote_path etc, which is not what I want - I want them to remain as quote_request_path etc.

And taking my example, I've also got quote_responses with response_items, and I want to have /responses/9/items/3 - which under your scheme would leave me with a clash between request_items and response_items URL helpers.

Of course, I could use name prefixes for my helpers and/or I can manually build my named routes, leaving map.resources behind.

However, map.resources is currently tightly coupling the interface (the URL elements) to the guts of my code and I want a more painless way to exert control over that. With this one-line change to resources.rb I can divorce the resource name in my code from the resource name in the URL.

Adding this option to two map.resources calls in my routes.rb I can change a url like:

/quotes/9/items/3

to

/anything/9/at_all/3

without *any* code changes (unless you had ActiveResource clients, in which case you'd have to change the name of your param for the resource entity in your controllers etc - a small change compared to the current alternatives).

I'm not saying anything is going to 'flop' without being able to easily make resource urls more opaque :-) but being able to do so has eased my pain and I think that others may benefit.

Trev

--
Rick Olson
http://weblog.techno-weenie.net
http://mephistoblog.com



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on 
Rails: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to