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?
Use constantize
:
class_name.singularize.constantize.columns
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With