I am trying to grab the Class object in a call I’m making, but the only place that I can find it is in params[:controller]. But this returns a string.
Can I find a Class object with just a string?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There’s a classify method that you can use to convert the string to an appropriately named constant, which in combination with
const_getshould be what you need. Here a simplified example, I don’t have a Rails console available at the moment:In Rails something like
should also work.