Sunday, 8 September 2013

Scope block ArgumentError with associations.

Scope block ArgumentError with associations.

I have a join table between Folders and Emails, and I have a user_id also
in my join tables model. In essence:
class Folder < ActiveRecord::Base
has_many :folder_emails,
:class_name => "FolderEmail"
has_many :emails, ->(user) { where user_id: user.id }, :through =>
:folder_emails
end
So, when I try to do Folder.find(1), I get the error: ArgumentError: wrong
number of arguments (3 for 1..2)
I'm new to the -> scope block syntax, and I can't comprehend why I'm
getting this error.

No comments:

Post a Comment