Hello! I need some help on something that seems very basic and ''noobish'' to me but that I cant figure out... I''m going to try to make it as simple as possible... I have a method that initializes an array. Let''s call it "main_view''. Why? Because it is the main view. The corresponding view - main_view.rhtml - does not do anything with this array, instead, it contains links to ajax-powered partials that let users alter this array in different ways, depending on what link they click on. If my page was made in ascii-''art'' and I had a 2 minutes deadline, it would probably look as bad as this: --------------------------------------------------- Add elements Remove elements Swap elements ___________ Partial to let user alter the array ___________ ---------------------------------------------------- So, when I click on a link, it goes to, for example, an "add_element" method and loads the partial. Then I edit/alter/... the array, + all those things users have to do. Then, once i am done, it goes to an "update_array" method that gets the data from the partial and updates the array with it. Now, the big problem i am facing : I cannot find how to cleanly and elegantly pass the array from my ''main_view'' method to the ''add_element'' (or other), then to the ''update'' method and finally back to ''main_view'' for another round of modifications. I could probably pass it like this, using hidden fields or whatever comes to my mind : main_view method => main_view.rhtml *user clicks on add element* => add_element method => _add_element.rhtml *user updates the array from the view and clicks on update* => update method => main_view.rhtml => ... But just thinking about how ugly it is is gonna make me have nightmares tonight. Or... I could make this array a sessions variable, but it''s not clean either as it might stay in the session variable for ever... And i dont want dust on my variables. So, is there any nice way of doing this? Am i missing something here, some part of Rails'' magic? Any help would be greatly appreciated, I am kinda tired and dont want to have nightmares tonight :) Thank you! Gedeon --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
You could use a session variable and store it all in that. -- Ryan Bigg http://www.frozenplague.net Feel free to add me to MSN and/or GTalk as this email. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thank you Ryan, Yes, I could do that but from what i read, it is not recommended because of unexpired sessions that will pile up and could create a performance problem... Which is why I am posting here. It should be ok for my project as it will have a limited number of users, but still, I''d rather like to make it clean and scalable... Besides, I''m sure I''ll bump into this problem again on other projects so I''ll need a better solution... Gedeon On Dec 27, 11:19 am, "Ryan Bigg" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> You could use a session variable and store it all in that. > -- > Ryan Bigghttp://www.frozenplague.net > Feel free to add me to MSN and/or GTalk as this email.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Store the object in a database and then link to directly to a user? I need to understand what you''re trying to do first. On Dec 27, 2007 3:37 PM, Gedeon <6edeon-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Thank you Ryan, > Yes, I could do that but from what i read, it is not recommended > because of unexpired sessions that will pile up and could create a > performance problem... Which is why I am posting here. > > It should be ok for my project as it will have a limited number of > users, but still, I''d rather like to make it clean and scalable... > Besides, I''m sure I''ll bump into this problem again on other projects > so I''ll need a better solution... > > Gedeon > > > On Dec 27, 11:19 am, "Ryan Bigg" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > You could use a session variable and store it all in that. > > -- > > Ryan Bigghttp://www.frozenplague.net > > Feel free to add me to MSN and/or GTalk as this email. > > >-- Ryan Bigg http://www.frozenplague.net Feel free to add me to MSN and/or GTalk as this email. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
@Gedeon: For something like this, I would definitely use the session. The purpose of the session is to persist data between requests. Do not worry about unexpired sessions... unless you have explicitly turned sessions OFF in your controllers, you''re already creating them. Investigate database session storage or cookie-based storage as they each have benefits and disadvantages. --~--~---------~--~----~------------~-------~--~----~ 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 guess I''ll do that then :-) I am already using the session variable but only for ''small'' things, such as the currently logged in user id, selected css id, ... For some reason, I was scared i might cause some kind of meltdown, lose my hair,... or even worse by storing ''bigger'' variables in there. Thank you, Gedeon On Dec 27, 12:18 pm, "Brian Hogan" <bpho...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> @Gedeon: > > For something like this, I would definitely use the session. The purpose of > the session is to persist data between requests. Do not worry about > unexpired sessions... unless you have explicitly turned sessions OFF in your > controllers, you''re already creating them. Investigate database session > storage or cookie-based storage as they each have benefits and > disadvantages.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
If the list they are creating is important enough that it should be stored in the database and displayed as a list to the user using something such as the "acts_as_list" plugin. If the list is not database worthy, then store it in the session. In Rails 2.0, session data is actually stored as an encrypted cookie on the client computer by default. All the data is stored on the client computer and as such there is no "cruft" to build up. Not to mention, you can clear the session data at any time once they are finished. There is really only five ways to persist data between actions (read: requests) : 1. Session 2. Cookies 3. Database 4. Files 5. Background Process For your needs, it seems that persisting an array would be best suited in the session or in the database. -- 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 -~----------~----~----~----~------~----~------~--~---
On Dec 26, 2007, at 11:26 PM, Gedeon wrote:> I guess I''ll do that then :-) > I am already using the session variable but only for ''small'' things,I was doing that for a while, but with large arrays things would get clobbered and I''d get a 500 error. What I did instead is put enough info in the the session to know how to rebuild the array. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hello You could investigate nondatabase Model too ... this model object could act as a wrapper for your array and persist between request (you may or may not store it in the session) Don''t really know if it would fit, you''ll have to investigate a bit. Gilles. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---