Rails where date is greater than given date query

后端 未结 3 1064
独厮守ぢ
独厮守ぢ 2021-02-03 17:04

Trying to search where movies coming out have a release date greater than today\'s date

 Movie.where(\'release > ?\', Date.today)
ActiveRecord::StatementInval         


        
3条回答
  •  南笙
    南笙 (楼主)
    2021-02-03 17:46

    Update

    Rails core team decided to revert this change for a while, in order to discuss it in more detail. See this comment and this PR for more info.

    I am leaving my answer only for educational purposes.


    new 'syntax' for comparison in Rails 6.1 (Reverted)

    Movie.where('release >': DateTime.now)
    

    Here is a link to PR where you can find more examples.

提交回复
热议问题