Good Friday Everyone :-).
These are my models:
Problem -> has_and_belongs_to_many :tags
Tag -> has_and_belongs_to_many :problems
Now if a tag does not exist and I create it and associate it to the
problem it works
self.tags << Tag.create(:name => tag)
But if I have the tag already in the DB and just want to link it to
another problem it does not really like me. I do it like this:
self.tags << Tag.find_by_name(tag)
I get the following error:
Mysql::Error: Duplicate entry ‘20’ for key 1: INSERT INTO
id) VALUES (20, 33, 20)
The problem is basically that it is trying to create a row in
problem_tags with an ‘id’ that already exists. How come it is trying
to do that? How can I prevent it from doing that?
Thanks for your help guys and gals!
http://www.soen.info - Index of online software engineering knowledge
http://www.cusec.net - Canadian University Software Engineering
http://www.soenlive.com - Presentations from CUSEC