0

Can someone please tell me what is wrong in this statement?

scope :between, -> (sender_id, recipient_id) do
where('(conversations.sender_id = ? AND conversations.recipient_id =?) OR (conversations.sender_id = ? AND conversations.recipient_id =?)', sender_id,recipient_id, recipient_id, sender_id)

end

NetBeans put a red line under it and says Unexpected tLPAREN_ARG

Thank you.

1 Answer 1

1

If you are using older version of ruby (1.9), it fails with that error message as you can't put space before the parameters in lambda call. May be your Netbeans setup has syntax checker for Ruby 1.9 configured. So the correct syntax for Ruby 1.9 should be:

scope :between, ->(sender_id, recipient_id) do
   where('(conversations.sender_id = ? AND conversations.recipient_id =?) OR (conversations.sender_id = ? AND conversations.recipient_id =?)', sender_id,recipient_id, recipient_id, sender_id)
end

Check the space between -> & (sender_id, recipient_id)

But your code should work with Ruby 2.0 and above.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.