0

I can see that the find method is now deprecated in rails. So what is the recommended way now?

Room.find(params[:id]

Even though Room.find_by_id(params[:id]) works just want to know the recommended way

Abhilash
  • 2,864
  • 3
  • 33
  • 67
  • 2
    Possible duplicate of ['ActiveRecord::Core::ClassMethods.find' call is deprecated](http://stackoverflow.com/questions/36480425/activerecordcoreclassmethods-find-call-is-deprecated) – Raj Apr 19 '16 at 12:22
  • 2
    Possible duplicate of [find(:first) and find(:all) are deprecated](http://stackoverflow.com/questions/15098961/findfirst-and-findall-are-deprecated) – Viktor Apr 19 '16 at 12:23
  • 2
    `.find(id)` is not depreciated and is in fact the recommended way. – max Apr 19 '16 at 12:24
  • @max But the docs also mentions its deprecated http://apidock.com/rails/ActiveRecord/Base/find/class – Abhilash Apr 19 '16 at 12:27
  • 2
    @Abhilash it was changed and moved to `Core`, not deprecated, see http://apidock.com/rails/ActiveRecord/Core/ClassMethods/find – Vasfed Apr 19 '16 at 12:29
  • 1
    Actually it is in [ActiveRecord::FinderMethods](http://api.rubyonrails.org/classes/ActiveRecord/FinderMethods.html#method-i-find). APIDock is not the official documentation for Rails and is often quite misleading. – max Apr 19 '16 at 12:34
  • Indeed it is..First rubymine throws the deprecated warning after I updated it today and when I saw the doc that mentioned its deprecrated.. Thank you all for the clarifiaction.. – Abhilash Apr 19 '16 at 12:34

1 Answers1

3

SomeModel.find(id) is not deprecated.

Deprecated is the old pre-rails-3 behavior of it:

SomeModel.find(:all, :conditions => { :approved => true })
Vasfed
  • 18,013
  • 10
  • 47
  • 53