Reputation: 6958
Say I have the model name saved in a variable:
"#{class_name.singularize}"
from another controller I want to see the columns defined for this model. I tried
send("#{class_name.singularize}.columns")
but its trying to call Page.columns
as a method of the class I am currently working in rather than the Page
class. Any ideas on how to do this?
Upvotes: 8
Views: 3546
Reputation: 96914
Use constantize
:
class_name.singularize.constantize.columns
Upvotes: 14