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

[Enh] Made the ActiveModel::Dirty#clear_attribute_changes method public #17545

Merged
merged 1 commit into from
Nov 6, 2014

Conversation

marzapower
Copy link
Contributor

In Rails 4.2 it is impossible to define a custom default value for a model's
attribute without making it appear as _changed?, especially when the model
is first initialized. Making this method public will allow such a behaviour,
without the need to use private APIs.

@@ -186,6 +186,11 @@ def restore_attributes(attributes = changed)
attributes.each { |attr| restore_attribute! attr }
end

# Remove changes information for the provided attributes.
def clear_attribute_changes(attributes)
Copy link
Member

Choose a reason for hiding this comment

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

We should keep it with private visibility and just add a # :doc: comment after the ) like we did with changes_applied

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've amended the commit just adding the # :doc: tag as suggested.

…e_changes method

In Rails 4.2 it is impossible to define a custom default value for a model's
attribute without making it appear as _changed?, especially when the model
is first initialized. Making this method publicly visible will allow such a behaviour,
without the need to use private APIs.
@rafaelfranca
Copy link
Member

Awesome! Thank you

rafaelfranca added a commit that referenced this pull request Nov 6, 2014
[Enh] Made the ActiveModel::Dirty#clear_attribute_changes method public
@rafaelfranca rafaelfranca merged commit 9a517b5 into rails:master Nov 6, 2014
@marzapower marzapower deleted the dirty_public_api branch November 6, 2014 19:00
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.

None yet

2 participants