Link to home
Start Free TrialLog in
Avatar of maxbillys
maxbillysFlag for Greece

asked on

Find class from string

I have many classes (models) called (something)Configuration.

I have a variable named "whatToDo"

Where whatToDo = "sendConfiguration"

What I want to do is    whatToDo.find_by_sql(sql)

It works if I write it sendConfiguration.find_by_sql(sql) but not whatToDo.find_by_sql(sql) where whatToDo = "sendConfiguration". Is there a method that finds a class from a string?
Avatar of Andrew Doades
Andrew Doades
Flag of United Kingdom of Great Britain and Northern Ireland image

you would need to do WhatToDo.find_by_sql(sql) with a capital W at the start?

This would define the model.
ASKER CERTIFIED SOLUTION
Avatar of wesgarrison
wesgarrison
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial