You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As a developer, if I am changing how a class is used or named, I would need to grep against the codebase with the name of the class. If this class is ever referenced via constantize then I will not find that reference without already knowing it's already there.
eg.
# Class definitionsclassAdminUser;endclassRegularUser;end# bad usageuser_klass="#{admin_accessible? ? "Admin" : "Regular")}User".constantize# good usageuser_klass=ifadmin_accessible?AdminUserelseRegularUserend
The solution:
I think using constantize is the issue here. I think there are cases where it needs to be used, but in general it causes the problem I outlined.
The text was updated successfully, but these errors were encountered:
I'm not too sure. constantize is a ActiveSupport method and I think my decision to put it here was based on making a rule around the usage of that method somehow. What's your thoughts on it, @pirj ?
The problem:
As a developer, if I am changing how a class is used or named, I would need to grep against the codebase with the name of the class. If this class is ever referenced via
constantize
then I will not find that reference without already knowing it's already there.eg.
The solution:
I think using
constantize
is the issue here. I think there are cases where it needs to be used, but in general it causes the problem I outlined.The text was updated successfully, but these errors were encountered: