On Domingo, 31 de Octubre de 2010 21:23:24 Benjamin Adler escribió: > On 08/09/2010 08:52 AM, Sergio Cambra .:: entreCables S.L. ::. wrote: > > On Viernes, 6 de Agosto de 2010 17:30:15 Benjamin Adler escribió: > >> Unfortunately the (deleted) record with id 119 is still in the database, > >> but has its attribute item_id updated from 3 to NULL. > >> > >> Why is that? What do I have to send in the params-hash to let the > >> controller delete this SA 119? > > > > AS doesn't delete unassociated records, they are deleted if you set > > :dependent to :delete_all or :destroy in your association definition. > > Sergio, for has_many and :dependent => delete_all this works fine now, > but I must have done something wrong with this class: > > class AntibodyInstance < ActiveRecord::Base > > has_one :storage_assignment, :as => :item, :conditions => "item_type > = 'AntibodyInstance'", :dependent => :delete > > has_one :storage, :through => :storage_assignment, :as => :item, > > :dependent => :delete > > ... > end > > When I edit the storage_assignment of an AntibodyInstance in AS and set > a different storage, the old StorageAssignment still remains in the > database with an item_id of NULL.
Sorry, I was busy in these days. You are editing AntibodyInstance or StorageAssignment? If you are editing AntibodyInstance, are you using has_one or has_one through in the form? > > If I create a new StorageAssignment in the console and overwrite an > AntibodyInstance's old StorageAssignment, that old StorageAssignment is > deleted correctly. So it seems to work with plain rails, but not with AS?! > > Why does it work for my has_many relationships, but not for has_one? > > cheers, > ben -- Sergio Cambra .:: entreCables S.L. ::. Mariana Pineda 23, 50.018 Zaragoza T) 902 021 404 F) 976 52 98 07 E) [email protected] -- You received this message because you are subscribed to the Google Groups "ActiveScaffold : Ruby on Rails plugin" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/activescaffold?hl=en.
