joshs
May 22, 2009, 3:19pm
1
I need the route /events/:event_id/races/edit, so:
map.resources :events do |event|
event.resources :races, :collection => {:edit => :get}
end
Which produces this:
edit_event_races GET /events/:event_id/races/edit(.:format)
{:action=>“edit”, :id=>/[^/.?]+/, :controller=>“races”}
This is exactly what I expected except for the weirdness over at :id
As a result, edit_event_races_path(@event ) or edit_event_races_path
(@event.id ) is blowing up in my face:
edit_event_races_url failed to generate from
{:controller=>“races”, :action=>“edit”, :event_id=>#<Event id: 1,
name: “Ride Sally Ride”>, :id=>/[^/.?]+/}
Am I doing something wrong here?
joshs
May 22, 2009, 3:25pm
2
I’m aware that the route /events/:event_id/races/:race_id/edit exists
but that is not what I want. My goal is to edit all the races
collectively, not individually, so I need the route mentioned above.
joshs
May 22, 2009, 3:31pm
3
Josh Sharpe wrote:
[…]
As a result, edit_event_races_path(@event ) or edit_event_races_path
(@event.id ) is blowing up in my face:
edit_event_races_url failed to generate from
{:controller=>“races”, :action=>“edit”, :event_id=>#<Event id: 1,
name: “Ride Sally Ride”>, :id=>/[^/.?]+/}
Am I doing something wrong here?
So it would seem. You’re passing an Event object where Rails is
apparently expecting an ID. Note what :event_id holds.
Best,
Marnen Laibow-Koser
http://www.marnen.org
[email protected]
joshs
May 22, 2009, 11:09pm
4
Sounds like what you’re after is an “event/#/index” that:
paginates the associated “races” into a
table that can be editted by
2a) individual field
2b) selected groups of fields
with a save that only saves modified “race” records
I may be wrong but that doesn’t sound like a restful route to me.