Apologies for the long title, but it bothers me. I am new to Rails, so this is my first project. Rails 3.0.3.
In my model, a Usermay or may not read a lot Entries; This is tracked in a model called ReadEntries. I think this many-to-one relationship is correctly defined in the code.
User.rb:
has_many :read_entries
Entry.rb:
has_many :read_entries
ReadEntry.rb:
belongs_to :entry
belongs_to :user
This table should be filled in at some point. If I try to do this:
user.read_entries.find_or_create_by_entry_id(entry.id, :read => false)
I get an error Unknown key(s): read. Leave trying to install :readand it works.
However, if I create the same line with this, it works:
ReadEntry.find_or_create_by_entry_id_and_user_id(entry.id, user.id, :read => false)
Logically, these methods should be the same, right? Thank.