Neale Yates
2006-Jan-02 11:34 UTC
[Rails] Many to Many relationship - trys to destroy twice??
I''m trying to work with a many to many relationship but since my join table need additional attributes I can''t use habtm. When I attempt to destroy an item from the join table RoR appears to attempt to destroy the item twice. Here is an example from the log file showing the process. The record is identified using a find_by_sql using the two id parameters (and a third ''position'' parameter for safety). The item is then apparently sucessfully destroyed, and the controller redirects to ''show_p''. Then it all goes wrong, and it appears to try to find the same record again. Has anyone seen this before? cheers Neale Processing AdminController#delete_i (for 127.0.0.1 at 2006-01-02 22:14:12) [POST] Parameters: {"pid"=>"2", "commit"=>"Delete", "action"=>"delete_i", "controller"=>"admin", "ingredient"=>{"ingredient_id"=>"64", "position"=>"8"}} Ingredients_Product Load (0.002288) SELECT * FROM ingredients_products WHERE (product_id = ''2'' and ingredient_id = ''64'' and position = ''8'') LIMIT 1 SQL (0.000563) BEGIN Ingredients_Product Columns (0.013075) SHOW FIELDS FROM ingredients_products Ingredients_Product Destroy (0.002416) DELETE FROM ingredients_products WHERE id = 50 SQL (0.001618) COMMIT Redirected to http://localhost:3000show_p Completed in 0.02861 (34 reqs/sec) | DB: 0.01996 (69%) | 302 Found [http://localhost/admin/delete_i?pid=2] Processing AdminController#delete_i (for 127.0.0.1 at 2006-01-02 22:14:12) [POST] Parameters: {"pid"=>"2", "commit"=>"Delete", "action"=>"delete_i", "controller"=>"admin", "ingredient"=>{"ingredient_id"=>"64", "position"=>"8"}} Ingredients_Product Load (0.004203) SELECT * FROM ingredients_products WHERE (product_id = ''2'' and ingredient_id = ''64'' and position = ''8'') LIMIT 1 NoMethodError (You have a nil object when you didn''t expect it! -- Posted via http://www.ruby-forum.com/.
Reasonably Related Threads
- messed-up habtm relationship
- setup problem, every request trys to download dispatch.fcgi
- [Bug 18234] New: c51 lvds script failure in randr12 mode. if I start the X server the screen is black and the framebuffer too because it trys to link the whole output to the monitor
- 06da:0002 Phoenixtec Power Co., Ltd UPS
- [IPD] Internet Probe Droid