I have this request
has_many :unused_invitations, :class_name => 'Invitation', :foreign_key => 'inviter_id', :conditions => 'used = false'
I used rails 3.2.17 and now I am upgrading to rails 4.0.4. I got this error
DEPRECATION WARNING: The following options in your User.has_many :unused_invitations declaration are deprecated: :conditions. Please use a scope block instead. For example, the following:
has_many :spam_comments, conditions: { spam: true }, class_name: 'Comment'
should be rewritten as the following:
has_many :spam_comments, -> { where spam: true }, class_name: 'Comment'
I solve it by modifying the request
has_many :used_invitations, class_name: 'Invitation', foreign_key: 'inviter_id', -> { where used: false}
But still I get a syntax error
syntax error, unexpected '\n', expecting => (SyntaxError)
What is wrong with the request? Someone explain to me about this. I sent this question, but can not find the answer.
source
share