I have three tables
class User < AR::Base
has_many :lexemes, :dependent => :destroy
end
class Lexeme < AR::Base
belongs_to :user
belongs_to :word
end
class Word < AR::Base
has_many :lexemes
end
This code is storing the word to Words table and assign it to the user.
word = Word.where(:word=>token).first_or_create
lexeme = @user.lexemes.where(:word_id=>word.id).first_or_create
I don't like my code, so is it possible to improve it? Thanks