sbfaulkner / selective_mapper

Selectively map resource routes to allow cleaner nesting of resources without having to specify redundant ids for parent resources.

selective_mapper / README.markdown
00656c1d » sbfaulkner 2008-08-18 change README to markdown 1 # SelectiveMapper
2
3 Selectively map resource routes to allow cleaner nesting of resources without having to specify redundant ids for parent resources.
4
846fcf0b » sbfaulkner 2008-09-03 add note regarding edge patch 5 ## IMPORTANT
6
7 A patch I submitted to edge rails recently has been accepted.
8
9 The update adds a :shallow option to the resources method eliminating my original need for this plugin.
10
11 This reduces the example from this document from ...
12
13 map.resources :companies do |company|
14 company.resources :people, :only => [ :collection, :new ]
15 end
16 map.resources :people, :except => [ :collection, :new ]
17
18 ... to ...
19
20 map.resources :companies, :shallow => true do |company|
21 company.resources :people
22 end
23
24 ... or ...
25
26 map.resources :companies, :shallow => true, :has_many => :people
27
00656c1d » sbfaulkner 2008-08-18 change README to markdown 28 ## Example
29
30 map.resources :companies do |company|
31 company.resources :people, :only => [ :collection, :new ]
32 end
33 map.resources :people, :except => [ :collection, :new ]
34
35 Results in...
36
37 companies GET /companies {:controller=>"companies", :action=>"index"}
38 formatted_companies GET /companies.:format {:controller=>"companies", :action=>"index"}
39 POST /companies {:controller=>"companies", :action=>"create"}
40 POST /companies.:format {:controller=>"companies", :action=>"create"}
41 new_company GET /companies/new {:controller=>"companies", :action=>"new"}
42 formatted_new_company GET /companies/new.:format {:controller=>"companies", :action=>"new"}
43 edit_company GET /companies/:id/edit {:controller=>"companies", :action=>"edit"}
44 formatted_edit_company GET /companies/:id/edit.:format {:controller=>"companies", :action=>"edit"}
45 company GET /companies/:id {:controller=>"companies", :action=>"show"}
46 formatted_company GET /companies/:id.:format {:controller=>"companies", :action=>"show"}
47 PUT /companies/:id {:controller=>"companies", :action=>"update"}
48 PUT /companies/:id.:format {:controller=>"companies", :action=>"update"}
49 DELETE /companies/:id {:controller=>"companies", :action=>"destroy"}
50 DELETE /companies/:id.:format {:controller=>"companies", :action=>"destroy"}
51 company_people GET /companies/:company_id/people {:controller=>"people", :action=>"index"}
52 formatted_company_people GET /companies/:company_id/people.:format {:controller=>"people", :action=>"index"}
53 POST /companies/:company_id/people {:controller=>"people", :action=>"create"}
54 POST /companies/:company_id/people.:format {:controller=>"people", :action=>"create"}
55 new_company_person GET /companies/:company_id/people/new {:controller=>"people", :action=>"new"}
56 formatted_new_company_person GET /companies/:company_id/people/new.:format {:controller=>"people", :action=>"new"}
57 edit_person GET /people/:id/edit {:controller=>"people", :action=>"edit"}
58 formatted_edit_person GET /people/:id/edit.:format {:controller=>"people", :action=>"edit"}
59 person GET /people/:id {:controller=>"people", :action=>"show"}
60 formatted_person GET /people/:id.:format {:controller=>"people", :action=>"show"}
61 PUT /people/:id {:controller=>"people", :action=>"update"}
62 PUT /people/:id.:format {:controller=>"people", :action=>"update"}
63 DELETE /people/:id {:controller=>"people", :action=>"destroy"}
64 DELETE /people/:id.:format {:controller=>"people", :action=>"destroy"}
65
66 ## Legal
67
68 **Author:** S. Brent Faulkner <brentf@unwwwired.net>
69 **License:** Copyright &copy; 2008 unwwwired.net, released under the MIT license