我正在使用带有rails 3.2.12的RubyMine,我在IDE中得到了不推荐使用的警告.任何想法如何解决这个已弃用的警告?
find(:first) and find(:all) are deprecated in favour of first and all methods. Support will be removed from rails 3.2.
解决方法
在@keithepley评论后我改变了我的回答
#Post.find(:all,:conditions => { :approved => true }) Post.where(:approved => true).all #Post.find(:first,:conditions => { :approved => true }) Post.where(:approved => true).first or post = Post.first or post = Post.first! or post = Post.last or post = Post.last!
您可以从this locations阅读更多内容
弃用声明
Post.find(:all,:conditions => { :approved => true })
更好的版本
Post.all(:conditions => { :approved => true })
最佳版本(1)
named_scope :approved,:conditions => { :approved => true } Post.approved.all
最佳版本(2)
Post.scoped(:conditions => { :approved => true }).all