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

Generate secure token only once regardless of on: :initialize or on: :create #49146

Merged
merged 1 commit into from Sep 5, 2023

Conversation

kamipo
Copy link
Member

@kamipo kamipo commented Sep 5, 2023

Follow-up to #47420.

Whereas the original behavior (on: :create) is invoked only once before a record is persisted, the new behavior (on: :initialize) is invoked not only new record but also persisted records.

It should be invoked only once for new record consistently.

…n: :create`

Follow-up to rails#47420.

Whereas the original behavior (`on: :create`) is invoked only once
before a record is persisted, the new behavior (`on: :initialize`) is
invoked not only new record but also persisted records.

It should be invoked only once for new record consistently.
@kamipo kamipo merged commit cf10924 into rails:main Sep 5, 2023
4 checks passed
@kamipo kamipo deleted the generating_token_only_once branch September 5, 2023 10:24
abeidahmed added a commit to abeidahmed/rails that referenced this pull request Dec 3, 2023
…alize

Follow-up to rails#49146

The original behavior of `has_secure_token` was to use the
`send("#{attribute}=", some_value)` method so that the setter method, if
defined, was called. PR rails#49146 replaced the `send` method with
`write_attribute` which doesn't call the setter method and breaks
existing applications.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant