Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding more finder deprecation info in upgrade documentation [ci skip] #12030

Merged
merged 1 commit into from
Aug 27, 2013

Conversation

garysweaver
Copy link
Contributor

Making changes mentioned in #12015 (comment) to add to finders info in Rails upgrade guide.

@@ -175,7 +175,9 @@ this gem such as `whitelist_attributes` or `mass_assignment_sanitizer` options.
* 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.
* The `find(...)` method can be replaced with `where(id: ...).first!`. If `id` is not the primary key, use the appropriate primary key. `where(id: ...).first!` will return an unspecific error message, "ActiveRecord::RecordNotFound", so if you need a message like the original finder, you'll need to use `first`, and if nil then raise manually, e.g. `raise ActiveRecord::RecordNotFound.new("Couldn't find (the model class name) with id=...")`. If you would rather return nil than raise an error when the requested record is missing, use `where(id: ...).first`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

find is not deprecated, why should the users replace it with the more verbose version?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, sorry about that.

@garysweaver
Copy link
Contributor Author

Thanks @senny. New changes look ok?

senny added a commit that referenced this pull request Aug 27, 2013
adding more finder deprecation info in upgrade documentation [ci skip]
@senny senny merged commit 60b9d4f into rails:master Aug 27, 2013
@senny
Copy link
Member

senny commented Aug 27, 2013

@garysweaver thank you for your contribution 💛

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants