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
On 4/27/06, Bing <sombreroisland@gmail.com> wrote:>
> 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
>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://wrath.rubyonrails.org/pipermail/rails/attachments/20060428/6c59ce95/attachment-0001.html