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

prefer Active Support's String#safe_constantize to #constantize #297

Merged
merged 1 commit into from
Dec 6, 2023

Conversation

flavorjones
Copy link
Collaborator

In #296, @kbrock pointed out that Rails uses String#safe_constantize when finding a Class from a class name.

Functionally I think this will be identical, so maybe there's no good reason to make the change other than "following Rails practices as closely as we can".

@flavorjones flavorjones requested a review from kbrock December 6, 2023 16:16
Copy link
Collaborator

@kbrock kbrock left a comment

Choose a reason for hiding this comment

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

Well, I haven't been able to determine when rails uses constantize and when they use safe_constantize

LGTM

@kbrock kbrock merged commit 13f1f59 into master Dec 6, 2023
13 checks passed
@kbrock kbrock deleted the flavorjones-safe-constantize branch December 6, 2023 22:16
kbrock added a commit to kbrock/active_hash that referenced this pull request Apr 29, 2024
- Support `has_many :through` associations active-hash#296 @flavorjones
- Rails 7.1 support active-hash#291 @y-yagi

- Rails 7.1: fix sqlite3 issue active-hash#303 @flavorjones
- Rails 7.1.3: add missing `has_query_constraints?` active-hash#300 @flavorjones
- `Array#pluck` supports methods active-hash#299 @iberianpig
- Prefer `safe_constantize` over `constantize` active-hash#297 @flavorjones
- Treat `nil` and `blank?` as different values active-hash#295 @kbrock
- Fix `#where` for string keys active-hash#292 @usernam3
kbrock added a commit to kbrock/active_hash that referenced this pull request Apr 29, 2024
- Ruby 3.3 support active-hash#298 @m-nakamura145
- Support `has_many :through` associations active-hash#296 @flavorjones
- Rails 7.1 support active-hash#291 @y-yagi

- Rails 7.1: fix sqlite3 issue active-hash#303 @flavorjones
- Rails 7.1.3: add missing `has_query_constraints?` active-hash#300 @flavorjones
- `Array#pluck` supports methods active-hash#299 @iberianpig
- Prefer `safe_constantize` over `constantize` active-hash#297 @flavorjones
- Treat `nil` and `blank?` as different values active-hash#295 @kbrock
- Fix `#where` for string keys active-hash#292 @usernam3
@kbrock kbrock mentioned this pull request Apr 29, 2024
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