0
我試圖用where.not替換下列麻煩:有使用where.not在軌
if @friend_matches.count > 0
@court_matches = Match.available_on_courts.where('matches.id NOT IN (?)', @friend_matches.pluck(:id)).to_a
else
@court_matches = Match.available_on_courts
end
隨着
@court_matches = Match.available_on_courts.where.not(matches.id: @friend_matches.pluck(:id)).to_a
但是我收到以下錯誤。
SyntaxError: /Users/sripaladugu/Coding/matchpoint_rails/app/mailers/match_mailer.rb:8: syntax error, unexpected ':'
...on_courts.where.not(matches.id: @friend_matches.pluck(:id))....
... ^
/Users/sripaladugu/Coding/matchpoint_rails/app/mailers/match_mailer.rb:8: syntax error, unexpected ')', expecting keyword_end
...id: @friend_matches.pluck(:id)).to_a
感謝您的快速回復。這解決了這個問題。 – calilonghorn
不客氣。 –