I have an instance variable @grp: (app\controllers\zwemmers_controller.rb) class ZwemmersController < ApplicationController ... def initialize @grp=''or1r2r3r4gggrp'' end attr_accessor :grp ... end When i click an image, i reload the main index page and try to change the value of the variable: (app\views\layouts\zwemmers.html.erb) ... <%= link_to image_tag("oranje.png", :mouseover => image_path("oranje2.png"), :grp => ''o''), zwemmers_path %> ... The value doesn''t change. any ideas? -- Posted via http://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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Feb 7, 2:19 pm, Kelly Pfaff <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I have an instance variable @grp: > (app\controllers\zwemmers_controller.rb) > class ZwemmersController < ApplicationController > ... > def initialize > @grp=''or1r2r3r4gggrp'' > endIn general I''d be wary of overriding initialize without calling super (i think you''re ok here though)> attr_accessor :grp > ... > end > > When i click an image, i reload the main index page and try to change > the value of the variable: > (app\views\layouts\zwemmers.html.erb) > > ... > <%= link_to image_tag("oranje.png", :mouseover => > image_path("oranje2.png"), :grp => ''o''), zwemmers_path %> > ... > > The value doesn''t change. any ideas?You haven''t shown anywhere where you''re trying to set it - if you want it to be set based on a parameter, you''re going to have to set @grp to params[:something] Fred> > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Frederick Cheung wrote in post #980057:> > You haven''t shown anywhere where you''re trying to set it - if you want > it to be set based on a parameter, you''re going to have to set @grp to > params[:something] >Hm, i forgot the on_click in my code: <%= link_to image_tag("oranje.png", :mouseover => image_path("oranje2.png"), :onclick => (:grp => ''o'')), zwemmers_path %> So when i click the image i want to redirect to zwemmers_path and i want to change the value of @grp to ''o''. I don''t know how to implement params tho. -- Posted via http://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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 7 February 2011 14:51, Kelly Pfaff <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Frederick Cheung wrote in post #980057: > >> >> You haven''t shown anywhere where you''re trying to set it - if you want >> it to be set based on a parameter, you''re going to have to set @grp to >> params[:something] >> > > Hm, i forgot the on_click in my code: > <%= link_to image_tag("oranje.png", :mouseover => > image_path("oranje2.png"), :onclick => (:grp => ''o'')), zwemmers_path %> > > So when i click the image i want to redirect to zwemmers_path and i want > to change the value of @grp to ''o''. I don''t know how to implement params > tho.If you don''t know about passing data back to the controller via params then you need to run through some basic guides and tutorials. See the Rails Guides (google it) and railstutorial.org is good. Make sure that any tutorial you use matches the rails version you are using (2 or 3). I would advise using Rails 3 unless you are to maintain legacy apps. Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
K thanks for the responses, i will do some reading on params. Didn''t know changing the value of an instance variable is this complicated. -- Posted via http://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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 7 February 2011 15:50, Kelly Pfaff <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> K thanks for the responses, i will do some reading on params. Didn''t > know changing the value of an instance variable is this complicated.It isn''t complicated, most things seem complicated till you know how and have had a bit of practice :) Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.