jruby google app engine error message: Multiple keys in #<KeywordUser @user_id=1 @keyword_id=2>
Models: (attempting to implement has and belongs to many relationship)
class Keyword
include DataMapper::Resource
property :id, Serial # required for DataMapper
property :name, String # A varchar type string, for short strings
has n, :users, :through => Resource
end
class User
include DataMapper::Resource
property :id, Serial # required for DataMapper
has n, :keywords, :through => Resource
end
(in the code)
newkeys.each_with_index do |key,index|
if Keyword.first(:name => key)
self.keywords << Keyword.first(:name => key) unless self.keywords.first(:name => key)
else
new_keyword = Keyword.create(:name => key)
new_keyword.save
self.keywords << new_keyword
self.save
end
end
self.save # error happens here