سؤال

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