Topic: named routes stopped working

Have a medium size restful app under development (~25 models). All the sudden my named routes started blowing up:
in my rhtml:

<% for bus in @buses %>
    <td><%=h %></td>
    <td><%=h bus.description %></td>
    <td><%=h bus.capacity %></td>
        <%= link_to 'Show', bus_path(bus), :class => "linkbutton_s" %>
      <%= link_to 'Edit', edit_bus_path(bus), :class => "linkbutton_s" %>
      <%= link_to 'Destroy', bus_path(bus), :confirm => 'Are you sure?', :method => :delete, :class => "linkbutton_s" %>
<% end %>

throws on bus_path(bus):

bus_url failed to generate from {:controller=>"buses", :action=>"show", :id=>#<Bus:0x2077568 @attributes={"name"=>"KB0", "updated_at"=>"2007-11-25 10:31:39", "location_id"=>"1", "description"=>"Cancel", "capacity"=>"0", "legacy_key"=>"{42F2E359-570D-485C-B3EC-19D4E3680882}", "created_at"=>"2007-11-25 10:31:39"}, @new_record=true>}, expected: {:controller=>"buses", :action=>"show"}, diff: {:id=>#<Bus:0x2077568 @attributes={"name"=>"KB0", "updated_at"=>"2007-11-25 10:31:39", "location_id"=>"1", "description"=>"Cancel", "capacity"=>"0", "legacy_key"=>"{42F2E359-570D-485C-B3EC-19D4E3680882}", "created_at"=>"2007-11-25 10:31:39"}, @new_record=true>}

The only significant thing i've done is move to 1.2.6, but upon seeing this I set the gem version to 1.2.5 in environment.rb. It is interesting to me that the @new_record attr is set to true even though the entity is not new, however new_record? seems to behave correctly.

This is happening for all my resource mapped models. Please help!

Re: named routes stopped working

Can you put your routes.rb file up?

Re: named routes stopped working

Actually I figured it out, I had put in a deep clone module ( … talk/55951) to DRY up my rhtml.

Problem was that options.clone is used for every url_for call, which was cloning my AR object causing it to be a new record not suitable for the show action path.

Sorry, I didn't close the thread, I figured this out and then collapsed from exhaustion for the night smile