Forum: Ruby on Rails Passing data between controller methods

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
E8f790714084c4c4e8eeefa796fbf765?d=identicon&s=25 lastest.trick@gmail.com (Guest)
on 2007-07-20 02:33
(Received via mailing list)
Hi All

What is the best way to pass data between different controller methods
in support of different views?

Thanks
Be07c8d0d6867fd9a0d525f7d17600e2?d=identicon&s=25 Damjan Rems (ther)
on 2007-07-23 14:44
lastest.trick@gmail.com wrote:
> Hi All
>
> What is the best way to pass data between different controller methods
> in support of different views?
>
> Thanks

I am trying to do the same but it looks like every controller gets its
own session, so variables can't be exchanged via session[].

It looks like rails feature.

Has anyone been dealing with the same problem.



by
TheR
83ca41657a99b65d99889abe712ba5e2?d=identicon&s=25 Jason Roelofs (Guest)
on 2007-07-23 14:49
(Received via mailing list)
Could you please explain what you mean by "passing data"? Do you mean
calling other methods in a controller or do you mean keeping information
around through different requests.

If you mean the latter, then your session is the way to go if that
information is not fit to be in the database.

Damjan, could you expound on your response? Controllers do not get their
own
session. The session is the construct built to keep information around
for
the entire time a user is using your site.

Jason
Be07c8d0d6867fd9a0d525f7d17600e2?d=identicon&s=25 Damjan Rems (ther)
on 2007-07-23 21:52
Jason Roelofs wrote:
> Could you please explain what you mean by "passing data"? Do you mean
> calling other methods in a controller or do you mean keeping information
> around through different requests.
>
> If you mean the latter, then your session is the way to go if that
> information is not fit to be in the database.
>
> Damjan, could you expound on your response? Controllers do not get their
> own
> session. The session is the construct built to keep information around
> for
> the entire time a user is using your site.
>
> Jason

I was playing with Ajax today and got this strange behaviour. If the
Ajax called method was in the same controller class, then Ajax call had
the same session ID (cleary seen in Mongrel). If the Ajax response
method was in another controller class, the call got different session
ID an thus proper session[] could not be reached in caller method.

I was testing loading some Ajax data on page load and it made me crazy
for over an hour until I changed the program and call Ajax method within
same controller.

by
TheR
This topic is locked and can not be replied to.