Routing changes in edge rails (map.resources now uses :has_many)

Posted on the May 17th, 2007 under programming,Ruby on Rails by John

For those of you working with edge rails, there were some major routing changes. I could not figure out what was going on when I performed a freeze on edge..
Here is why: Changeset 6594 and Changeset 6588 – Hopefully this will help prevent some headaches.


* Added :name_prefix as standard for nested resources [DHH]. WARNING: May be backwards incompatible with your app
4
5 Before:
6
7 map.resources :emails do |emails|
8 emails.resources :comments, :name_prefix => "email_"
9 emails.resources :attachments, :name_prefix => "email_"
10 end
11
12 After:
13
14 map.resources :emails do |emails|
15 emails.resources :comments
16 emails.resources :attachments
17 end
18
19 This does mean that if you intended to have comments_url go to /emails/5/comments, then you'll have to set :name_prefix to nil explicitly.
20
21 * Added :has_many and :has_one for declaring plural and singular resources beneath the current [DHH]
22
23 Before:
24
25 map.resources :notes do |notes|
26 notes.resources :comments
27 notes.resources :attachments
28 notes.resource :author
29 end
30
31 After:
32
33 map.resources :notes, :has_many => [ :comments, :attachments ], :has_one => :author
2 34
3 35 * Added that render :xml will try to call to_xml if it can [DHH]. Makes these work:

Similar Posts:

One Response to 'Routing changes in edge rails (map.resources now uses :has_many)'

  1. May 17, 2007 at 11:26 pm
    john burmeister

Leave a Reply




XHTML::
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>