ok this is really basic rails question, but how do I keep an object alive between controller action? I thought I could create an object and it would remain alive, but I am guessing the controller object gets recreated each time? -- Kind Regards, Rajinder Yadav -- 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 Sun, Feb 28, 2010 at 2:09 PM, Rajinder Yadav <devguy.ca-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> ok this is really basic rails question, but how do I keep an object alive > between controller action? I thought I could create an object and it would > remain alive, but I am guessing the controller object gets recreated each > time? > >Rajinder, you can store the object in a session. For example, you can do the following: Store: session[:object_to_persist] = an_object Retrieve: some_local_variable = session[:object_to_persist] For further information, I would recommend reading the relevant section from "Agile Web Development with Rails 3rd" by Dave Thomas et al. Good look, -Conrad> -- > Kind Regards, > Rajinder Yadav > > -- > 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.
Conrad Taylor wrote:> On Sun, Feb 28, 2010 at 2:09 PM, Rajinder Yadav <devguy.ca > <http://devguy.ca>@gmail.com <http://gmail.com>> wrote: > > ok this is really basic rails question, but how do I keep an object > alive between controller action? I thought I could create an object > and it would remain alive, but I am guessing the controller object > gets recreated each time? > > > Rajinder, you can store the object in a session. For example, you can > do the following: > > Store: > > session[:object_to_persist] = an_object > > Retrieve: > > some_local_variable = session[:object_to_persist] > > For further information, I would recommend reading the relevant section > from "Agile Web Development with Rails 3rd" by Dave Thomas et al.Hi Conrad, thanks I was not sure session object was the right way to do things. I''ve got 3 books on Rails and I''m hoping to get "Agile Web Development with Rails 3rd" soon =) but I''ll will check out the section now.> > Good look, > > -Conrad > > > -- > Kind Regards, > Rajinder Yadav >-- 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 Sun, Feb 28, 2010 at 2:36 PM, Rajinder Yadav <devguy.ca-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Conrad Taylor wrote: > > On Sun, Feb 28, 2010 at 2:09 PM, Rajinder Yadav <devguy.ca < >> http://devguy.ca>@gmail.com <http://gmail.com>> wrote: >> >> ok this is really basic rails question, but how do I keep an object >> alive between controller action? I thought I could create an object >> and it would remain alive, but I am guessing the controller object >> gets recreated each time? >> >> >> Rajinder, you can store the object in a session. For example, you can do >> the following: >> >> Store: >> >> session[:object_to_persist] = an_object >> >> Retrieve: >> >> some_local_variable = session[:object_to_persist] >> >> For further information, I would recommend reading the relevant section >> from "Agile Web Development with Rails 3rd" by Dave Thomas et al. >> > > Hi Conrad, > > thanks I was not sure session object was the right way to do things. I''ve > got 3 books on Rails and I''m hoping to get "Agile Web Development with Rails > 3rd" soon =) but I''ll will check out the section now. > >Rajinder, you can read the section on "Cart Creation". Also, there''s later section(s) in the book that goes into greater detail. Good luck, -Conrad> > >> Good look, >> >> -Conrad >> >> -- Kind Regards, >> Rajinder Yadav >> >> > -- > 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.
Conrad Taylor wrote:> On Sun, Feb 28, 2010 at 2:36 PM, Rajinder Yadav <devguy.ca > <http://devguy.ca>@gmail.com <http://gmail.com>> wrote: > > Conrad Taylor wrote: > > On Sun, Feb 28, 2010 at 2:09 PM, Rajinder Yadav <devguy.ca > <http://devguy.ca> <http://devguy.ca>@gmail.com > <http://gmail.com> <http://gmail.com>> wrote: > > ok this is really basic rails question, but how do I keep an > object > alive between controller action? I thought I could create an > object > and it would remain alive, but I am guessing the controller > object > gets recreated each time? > > > Rajinder, you can store the object in a session. For example, > you can do the following: > > Store: > > session[:object_to_persist] = an_object > > Retrieve: > > some_local_variable = session[:object_to_persist] > > For further information, I would recommend reading the relevant > section from "Agile Web Development with Rails 3rd" by Dave > Thomas et al. > > > Hi Conrad, > > thanks I was not sure session object was the right way to do things. > I''ve got 3 books on Rails and I''m hoping to get "Agile Web > Development with Rails 3rd" soon =) but I''ll will check out the > section now. > > > Rajinder, you can read the section on "Cart Creation". Also, there''s > later section(s) in the book that goes into greater detail.Conrad, thanks again =) it''s working like a charm and I''ll read the entire section on "Cart Creation" tonight! Kind Regards, Rajinder Yadav> > Good luck, > > -Conrad > > > > > Good look, > > -Conrad > > -- Kind Regards, > Rajinder Yadav-- 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.