Question

How can i use strings as varibles in ruby and assign values to it for eg:

"@" + "Patient".downcase = Patient.all.last

Thanks!

Was it helpful?

Solution

If you mean instance variables, you can do this:

instance_variable_set('@' + 'Patient'.downcase, Patient.last)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top