質問

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