Yudi Soesanto
2010-Mar-19 08:12 UTC
how to preserve the value from the other action controller
Hi, Anyone knows how to preserve the value from the previous action controller? For example, - I have 2 controllers: foo_one and foo_two. - on action foo_one, I have variable @my_value - How I can keep the value of @my_value so I can use it on the second controller foo_two def foo_one @my_value = params[:preserve_value] end def foo_two puts @preserve_value end I don''t want to use session or global variable. any suggestion? Yudi Soesanto -- 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.
Andy Jeffries
2010-Mar-19 09:36 UTC
Re: how to preserve the value from the other action controller
On 19 March 2010 08:12, Yudi Soesanto <soesanty-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > Anyone knows how to preserve the value from the previous action controller? > > For example, > - I have 2 controllers: foo_one and foo_two. > - on action foo_one, I have variable @my_value > - How I can keep the value of @my_value so I can use it on the second > controller foo_two > > def foo_one > @my_value = params[:preserve_value] > end > > def foo_two > puts @preserve_value > end > > > I don''t want to use session or global variable. any suggestion? >Assuming foo_one calls foo_too (so it''s in the same request - hence your global variable mention), then you could define an attr_accessor on foo_two''s controller and set it from there. But, if it''s not being executed in the same request, session (be it Rails session, database or memcached) is the only way (or flash so it''s automatically removed after the next request). Cheers, Andy -- 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.
Yudi Soesanto
2010-Mar-19 10:10 UTC
Re: how to preserve the value from the other action controller
Thanks for your reply. I will do research on memcached Yudi Soesanto On Fri, Mar 19, 2010 at 5:36 AM, Andy Jeffries <andyjeffries-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> On 19 March 2010 08:12, Yudi Soesanto <soesanty-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> Hi, >> >> Anyone knows how to preserve the value from the previous action >> controller? >> >> For example, >> - I have 2 controllers: foo_one and foo_two. >> - on action foo_one, I have variable @my_value >> - How I can keep the value of @my_value so I can use it on the second >> controller foo_two >> >> def foo_one >> @my_value = params[:preserve_value] >> end >> >> def foo_two >> puts @preserve_value >> end >> >> >> I don''t want to use session or global variable. any suggestion? >> > > Assuming foo_one calls foo_too (so it''s in the same request - hence your > global variable mention), then you could define an attr_accessor on > foo_two''s controller and set it from there. > > But, if it''s not being executed in the same request, session (be it Rails > session, database or memcached) is the only way (or flash so it''s > automatically removed after the next request). > > Cheers, > > > Andy > > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- 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.