if request.post? @sport_field.attributes = params[:sport_field] @sport.sport_fields << @sport_field
redirect_to :action => “list”, :sport_id => params[:sport_id] and
return if @sport_field.save
end
end
So if i hit my list page and then click the new link (<%= link_to “New
field for: #{@sport.name}”, :action => ‘edit’, :sport_id => @sport.id
%>)
everything is cool and my new object is created and saved, I am
redirected back to the list page
Now if I hit new again it somehow finds the last object i created and
popuates the field values AND the form action with the id of the
previous object.
This is the wierdest thing… the log file:
Processing SportFieldController#edit (for 127.0.0.1 at 2006-11-03
18:57:09) [GET]
Session ID: 5d3f3c4e8af29b3ad4dc5da66034a1cd
Parameters: {“action”=>“edit”, “sport_id”=>“9”,
“controller”=>“admin/sport_field”}
Sport Columns (0.008294) SHOW FIELDS FROM sports
Sport Load (0.006463) SELECT * FROM sports WHERE (sports.id = 9)
FieldType Load (0.000939) SELECT * FROM field_types
SportField Columns (0.007362) SHOW FIELDS FROM sport_fields
SportField Load (0.007752) SELECT * FROM sport_fields WHERE
(sport_fields.id IS NULL ) LIMIT 1
41
Rendering within layouts/main
Rendering admin/sport_field/edit
So it selects the opject with ID NULL but finds and logs a id of 40 (in
this case)
I have switched to database session mgmt just in case. No change.
Anybody seen this before?
Thanks,
-Dinshaw
Processing SportFieldController#edit (for 127.0.0.1 at 2006-11-03
18:57:09) [GET]
Session ID: 5d3f3c4e8af29b3ad4dc5da66034a1cd
Parameters: {“action”=>“edit”, “sport_id”=>“9”,
“controller”=>“admin/sport_field”}
Sport Columns (0.008294) SHOW FIELDS FROM sports
Sport Load (0.006463) SELECT * FROM sports WHERE (sports.id = 9)
FieldType Load (0.000939) SELECT * FROM field_types
SportField Columns (0.007362) SHOW FIELDS FROM sport_fields
SportField Load (0.007752) SELECT * FROM sport_fields WHERE
(sport_fields.id IS NULL ) LIMIT 1
41
Rendering within layouts/main
Rendering admin/sport_field/edit
So it selects the opject with ID NULL but finds and logs a id of 40 (in
this case)
Hi and thanks for the reply.
I am using mysql and i checked out the head of the repository into
vendor at the begining of this month.
Here is something else strange, if you refreash the page that has the
phantom object’s info, it goes away and acts as if (correctly) I was
createing a new object.
So change your code in the way suggested in this post, which is
the same as I suggested in my original reply.
Thank you very much Mark. I was heistant to change that because it is
straight out ot Rails Recipies. I will plug in your fix as soon as I am
off the clock.
Thanks again
-Dinshaw
Hi and thanks for the reply.
I am using mysql and i checked out the head of the repository into
vendor at the begining of this month.
Here is something else strange, if you refreash the page that has the
phantom object’s info, it goes away and acts as if (correctly) I was
createing a new object.