I have this query
has_many :unused_invitations, :class_name => 'Invitation', :foreign_key => 'inviter_id', :conditions => 'used = false'
I was using 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 query
has_many :used_invitations, class_name: 'Invitation', foreign_key: 'inviter_id', -> { where used: false}
But Still I getting syntax error
syntax error, unexpected '\n', expecting => (SyntaxError)
What is wrong with query ? Will someone explain me about it. I have go this question but can't find the answer.
Solve this problem by updating the query
has_many :used_invitations, -> { where used: false}, class_name: 'Invitation', foreign_key: 'inviter_id'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With