Hello, I understand that it is not good practice in rails to store objects in the session[] and to instead just store id''s of model objects.. could someone please explain why this is? If this is true, i was wondering if it was also better practice to pass id''s between methods as opposed to passing objects? Is the performance of the application a factor in deciding this? I also have an issue of whether to have fairly large controller methods or to split them up and use redirect_to between the methods.. basically, the large method would be reused a lot and so would have to have many ''if'' statements in to account for all instances of its use.. or the smaller ones would account for the different instances and would use redirect_to to use common code ?? Any thoughts on these issues would be very much appreciated! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
hi, Can you point me to the article or which book you have read that discourages in storing objects in session[] Thanks On Jan 31, 8:05 am, James Smith <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hello, > > I understand that it is not good practice in rails to store objects in > the session[] and to instead just store id''s of model objects.. could > someone please explain why this is? > > If this is true, i was wondering if it was also better practice to pass > id''s between methods as opposed to passing objects? > > Is the performance of the application a factor in deciding this? > > I also have an issue of whether to have fairly large controller methods > or to split them up and use redirect_to between the methods.. basically, > the large method would be reused a lot and so would have to have many > ''if'' statements in to account for all instances of its use.. or the > smaller ones would account for the different instances and would use > redirect_to to use common code ?? > > Any thoughts on these issues would be very much appreciated! > > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 1/30/07, James Smith <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Hello, > > I understand that it is not good practice in rails to store objects in > the session[] and to instead just store id''s of model objects.. could > someone please explain why this is? > > If this is true, i was wondering if it was also better practice to pass > id''s between methods as opposed to passing objects? > > Is the performance of the application a factor in deciding this? > > I also have an issue of whether to have fairly large controller methods > or to split them up and use redirect_to between the methods.. basically, > the large method would be reused a lot and so would have to have many > ''if'' statements in to account for all instances of its use.. or the > smaller ones would account for the different instances and would use > redirect_to to use common code ?? > > Any thoughts on these issues would be very much appreciated! > > -- > Posted via http://www.ruby-forum.com/. > > > >This will answer part of your question: http://www.therailsway.com/2007/1/10/assetsgraphed-part-2 -- Zack Chandler http://depixelate.com --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi James, james_027 wrote:> Can you point me to the article or which book you > have read that discourages in storing objects in session[]"Agile Web Development with Rails", p. 314 "You probably don''t want to store massive objects in session data -- put them in the database and reference them from the session." The key here is to understand that if, for example, you have an object that ''has many'' other objects, when you store the parent object in the session, all the children get stored too. hth, Bill --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I see you point bill, what if the object doesn''t have child objects? Is there a way to tell rails that by default the child object will not be retrieve until needed? will it be much more efficient to store the id of the object in the session and perform a lot of find operation (sql query)? how do we evaluate the two solutions? thanks On Jan 31, 9:03 am, "Bill Walton" <bill.wal...-xwVYE8SWAR3R7s880joybQ@public.gmane.org> wrote:> Hi James, > > james_027 wrote: > > Can you point me to the article or which book you > > have read that discourages in storing objects in session[] > > "Agile Web Development with Rails", p. 314 > "You probably don''t want to store massive objects in session data -- put > them in the database and reference them from the session." > > The key here is to understand that if, for example, you have an object that > ''has many'' other objects, when you store the parent object in the session, > all the children get stored too. > > hth, > Bill--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 1/31/07, james_027 <cai.haibin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I see you point bill, what if the object doesn''t have child objects?There''s also the staleness issue. Loading from db on each request ensures that you''re working with current data. Isak --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---