Forum: Ruby on Rails Question about instant variable in views and request paramet

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
A0bae8a464f7bdae361c4a07e4f84cd8?d=identicon&s=25 (Guest)
on 2006-12-31 00:38
(Received via mailing list)
Hi all,

I have a difficulty which I would like to ask for help.

I passed parameters to a view in the form of URL parameters
(...?param1=xxx&param2=yyy), and use these parameters to initialize an
instant variable (say @var1) in an action method of my controller. In
that view there're some AJAX stuffs. Following are my difficulty:

1. In subsequent action methods called by AJAX, I need to access the
@var1 (already initialized before), but @var1 return nil. How could i
keep the value of @var1 across action methods? I guess the controller
is singleton, so @var1 will be like a global variable and its value
will be kept available across requests - but clearly it's not the case.
Could anyone explain how I'm wrong?

2. I would like to re-initialize @var1 using request parameters
(param1, param2...). However in subsequent action methods called by
AJAX stuffs, how can I access these parameters, as they're not in
params any more (they're still there on URL).

Sorry for these newbie questions. Thank a lot for help.

- Chuong
This topic is locked and can not be replied to.