Skip to content

Simplification of model_exists? in the serializable generator #153

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

Open
jgomo3 opened this issue Apr 11, 2025 · 0 comments
Open

Simplification of model_exists? in the serializable generator #153

jgomo3 opened this issue Apr 11, 2025 · 0 comments

Comments

@jgomo3
Copy link

jgomo3 commented Apr 11, 2025

That method could be written:

def model_exists?
  Rails.application.eager_load!
  ApplicationRecord.descendants.any? { _1.name == class_name }
end

Instead of:

def model_exists?
  Rails.application.eager_load!
  models = ApplicationRecord.descendants.map(&:name)
  !!models.find { |model_name| model_name == class_name }
end
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

No branches or pull requests

1 participant