Permalink
Browse files

Merge pull request #12015 from vipulnsward/add_dynamic_finders_to_upg…

…rade

Add Finder API changes to upgrading guide [ci skip]
  • Loading branch information...
1 parent 94f44ee commit cd02e68db10ff7ffcb0d2fb0ef31eccdb58478b2 @steveklabnik steveklabnik committed with rafaelfranca Aug 26, 2013
Showing with 12 additions and 0 deletions.
  1. +12 −0 guides/source/upgrading_ruby_on_rails.md
@@ -74,6 +74,18 @@ this gem such as `whitelist_attributes` or `mass_assignment_sanitizer` options.
* Rails 4.0 has deprecated `ActiveRecord::Fixtures` in favor of `ActiveRecord::FixtureSet`.
* Rails 4.0 has deprecated `ActiveRecord::TestCase` in favor of `ActiveSupport::TestCase`.
+* Rails 4.0 has deprecated the old-style hash based finder API. This means that
+ methods which previously accepted "finder options" no longer do.
+
+* All dynamic methods except for `find_by_...` and `find_by_...!` are deprecated.
+ Here's how you can handle the changes:
+
+ * `find_all_by_...` becomes `where(...)`.
+ * `find_last_by_...` becomes `where(...).last`.
+ * `scoped_by_...` becomes `where(...)`.
+ * `find_or_initialize_by_...` becomes `find_or_initialize_by(...)`.
+ * `find_or_create_by_...` becomes `find_or_create_by(...)`.
+
### Active Resource
Rails 4.0 extracted Active Resource to its own gem. If you still need the feature you can add the [Active Resource gem](https://github.com/rails/activeresource) in your Gemfile.

0 comments on commit cd02e68

Please sign in to comment.