Change String “@patient” to variable
-
20-12-2019 - |
سؤال
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)
لا تنتمي إلى StackOverflow