[Rails] Re: Global variables and assigning the values
On Nov 18, 8:21 am, Robert Negronida <li...@ruby-forum.com> wrote:
> I am having an issue where the global variable, $r, which i declared in
> the controller is being overwritten by my code which is in a view:
>
> <%= link_to 'Picks test1', game_pick_page_path, :onclick => $r = 1 %>
> <%= link_to 'Picks test2', game_pick_page_path, :onclick => $r = 2 %>
>
> The first $r = 1 is overwritten by $r = 2 making the value 2 even if i
> click picks test1. i want it to just set $r to which every value is
> associated with the link the user clicks.
>
I'm not sure what you trying to do. If you don't want the global to be
changed, why are you assigning to it? Legitimate uses are few and far
between, I'm sure an alternative can be suggested if you can clarify
your intent.
Fred.
> Any ideas on how to make this happen would be greatly appreciated.
>
> --
> Posted viahttp://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home