find(:first) and find(:all) are deprecated

后端 未结 3 399
死守一世寂寞
死守一世寂寞 2020-12-19 06:36

I am using RubyMine with rails 3.2.12 and I am getting following deprecated warning in my IDE. Any Idea How can I solve this deprecated warning?

3条回答
  •  囚心锁ツ
    2020-12-19 06:57

    Here is the Rails 3-4 way of doing it:

    Post.where(approved: true) # All accepted posts
    Post.find_by_approved(true) # The first accepted post
    # Or Post.find_by(approved: true)
    # Or Post.where(approved: true).first
    Post.first
    Post.last
    Post.all
    

提交回复
热议问题