Вопрос

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

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

Thanks!

Это было полезно?

Решение

If you mean instance variables, you can do this:

instance_variable_set('@' + 'Patient'.downcase, Patient.last)
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top