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.
