From: Stefan Rusterholz Date: 2009-01-22T18:43:52+09:00 Subject: Re: How to change ruby's global variable through onclick ev Vikas Gholap wrote: > Hello all, > > I have problem that how to change ruby's global variable through onclick > event.? > > my code is like in myvideo.html.erb file. > -------------------------------------------------------------------------- > onclick=\"something that change variable\">More videos > -------------------------------------------------------------------- > through onclick how can i change variable declared in my_controller.rb > > ------------------------------------------------------- > class myController < ApplicationController > $moreVideo = false > > def moreVideo > $moreVideo = true > respond_to do |format| > format.html { render_partial 'home/video_search' } > end > > end > > end > -------------------------------------------------------------- > > is there way to change $moreVideo=true through onclick or href of anchor > tag given above. Hi You're probably better off in the rubyonrails mailing list instead of the ruby ML. However, a short answer anyway: to change values on the server side (that's where your ruby code is) upon client side events (where there's no executed ruby code anymore) you'll need a client side code such as javascript e.g. using ajax to communicate that event to the server side. On another note: you do NOT want a global variable there. A global will be used not just for that single user but for all happening to be served by the same instance of ruby. Regards Stefan -- Posted via http://www.ruby-forum.com/.