Hi,
I managed to get the complex forms and nested resources described in
http://railscasts.com/episodes/75-complex-forms-part-3 to work.
But I''m having problems when deleting a sub item.
def existing_task_attributes=(task_attributes)
tasks.reject(&:new_record?).each do |task|
attributes = task_attributes[task.id.to_s]
if attributes
task.attributes = attributes
else
tasks.delete(task)
end
end
end
the tasks.delete(task) gives me a mysql error: Mysql::Error: Cannot add
or update a child row: a foreign key constraint fails
My main item has several sub items and a sub item belongs to the main
item. In my mysql database, the constraint is set at the sub item table,
pointing to the main item id and on delete => cascade.
Anyone has an idea on what is going on? Why this is giving me an error?
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---