Reputation: 1416
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
I keep getting an error that says:
warning: invalid character syntax; use ?\s
How do I fix this?
Upvotes: 1
Views: 83
Reputation: 101811
You are using angled double quotation marks (“
and ”
) which is not a valid string delimiter for literals in Ruby. Usually this happens if you are are copying text into an editor not meant for programming like MS Word. Valid delimeters are '
and "
.
You can also improve the readability greatly by using named instead of ordinal placeholders.
scope :between, -> (sender_id,recipient_id) do
where(
"(conversations.sender_id = :s AND conversations.recipient_id = :r ) OR (conversations.sender_id = :r AND conversations.recipient_id = :s)",
s: sender_id, r: recipient_id
)
end
Upvotes: 1
Reputation: 5521
Your quotation marks are not the standard ones but some weird utf8 characters, use " or ' instead. The error message ist pretty misleading. Some editors are using this format which is not valid for rails.
Upvotes: 1