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?
您的引号不是标准的引号,而是一些奇怪的utf8字符,请改用“或”。错误消息可能会误导您。某些编辑器使用的是这种格式,不适用于rails。
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.