Trying to turn params field into a variable

Hi guys,

I have another question, we have this line on our .rb code:

@variable = params [:user][:bird]

I need to be able to change the 2nd field into a variable because it is
a changing valuename, I was wondering if you had any trick for that.
Meaning I need to make [:bird] into [:dog] or [:cat]…

It’s proven really tricky for me to get it to change I wonder if you
guys had any suggestions to it.

thanks,

Bing

You should be able to use the to_sym method to turn your variable name
into
a symbol.

varname = “monkey”
@variable params [:user][varname.to_sym]

-Steve
http://www.stevelongdo.com

Hi Steve,

thanks so much, your solution works great!

Bing