On Lunes, 12 de Abril de 2010 18:54:16 Soren Christensen escribió: > Exactly, > > so when you delete with > > DELETE FROM `roles_users` WHERE user_id = 2 AND role_id IN (2,2) > > then both entries are deleted, but AS only redraws one of the entries. > Should it now redraw both entries ?
Are you talking about remove link in a nested scaffold? Remove link will remove a row with the removed id, id in HTML should be unique so really it shouldn't be a duplicated associated record, it has no point. I have added a check in edit_associated in order to don't add an existing record, but it's only for default subforms. Using add existing from nested scaffold you can still add duplicated records, I could add a check in add_existing controller action, but I'm not sure is good. Setting :uniq => true in association definition fixes showing as list column and subform (removing duplicates), but it's not fully fixed, nested scaffold still shows duplicated records. What do you think about this? > > /S > > On 4/12/2010 1:18 AM, Sergio Cambra .:: entreCables S.L. ::. wrote: > > On Domingo, 11 de Abril de 2010 23:42:01 Soren Christensen escribió: > >> Hi, > >> > >> Seems that there is a bug in AS. > >> > >> If you have a HABTM relation where there happens to be multiple > >> identical entries, then you can not delete one of the copies, but you > >> have to delete them ALL, update, edit again and then add a single copy > >> back. > >> > >> /S > > > > It's not possible to delete one of the identical associations. > > > > If you have an user which has and belongs to many roles, the join table > > will be roles_users with two fields: role_id and user_id. For example, > > you have user with id 1, and two identical associations with the role > > with id 2. The table will be: > > > > role_id | user_id > > ------------------------ > > 2 | 1 > > 2 | 1 > > > > To delete an association you would use the following query: > > DELETE FROM `roles_users` WHERE user_id = 2 AND role_id IN (2,2) > > > > But that query will remove both identical associations. > > > > So, you shouldn't have duplicated associations with that table. -- 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.
