Forums » Development »
Group.find do an insert
Added by Alexandre Sabán almost 11 years ago
Hi,
I have a problem when I try do find a group in a plugin.
I changed the users table by adding "external_id" column (integer) because I need to save the external ID of the group but when I try to find the group, an insert is performed.
My code is :
group = Group.first(:conditions => "external_id = #{team['id']}")
The SQL:
Creating scope :sorted. Overwriting existing method Group.sorted. Group Load (0.2ms) SELECT `users`.* FROM `users` WHERE `users`.`type` IN ('Group') AND (external_id = 1) LIMIT 1 (0.2ms) BEGIN (0.6ms) INSERT INTO `groups_users` (`group_id`, `user_id`) VALUES (223, 224) Mysql2::Error: Duplicate entry '223-224' for key 'groups_users_ids': INSERT INTO `groups_users` (`group_id`, `user_id`) VALUES (223, 224) (0.2ms) ROLLBACK Completed 500 in 1372ms
I do not understand why an insert is performed
Please help !!!
Sorry for my english !