er_tanoso-s8PdfxpoPdHk1uMJSBkQmQ@public.gmane.org
2005-May-28 12:46 UTC
Deleting from a ''has_many'' collection doesn''t set the foreign key to NULL (fwd)
er_tanoso-s8PdfxpoPdHk1uMJSBkQmQ@public.gmane.org writes:>> class Sale < ActiveRecord::Base >> has_many :sale_line_items, :class_name ''SaleLineItem'' >> >> ... >> >> end >> >> class SaleLineItem < ActiveRecord::Base >> ... >> >> end >> >> When I try to delete an item in a Sale class method from sale_line_items >> (sale_line_items.delete(li)), it extracts ''li'' from the container as >> expected, but it doesn''t set the foreign_key ''sale_id'' to NULL as >> especified in the documentation.> Does SaleLineItem belongs_to :sale? AR needs to know there''s a foreign > key in sale_line_items linking it to the sale. The belongs_to keyword > is what sets this up.> doug-jGAhs73c5XxeoWH0uzbU5w@public.gmane.orgSorry for my delay to reply, I''ve done what you say (I really thougth it was the solution), SaleLineItems belongs_to Sale now, but I get the same problem. May this be a BUG??. Many thanks in advance.