As I learn Rails I find myself all too often tempted to dump something into the session hash just because I can''t think of a better way to make it briefly persistent (no oxymoron intended!). For instance, I have report that allows all sorts of changes by the user. He can set filters on the data, sort it in different ways, and so on. Different Actions get involved, but each of them needs to see the underlying data. It makes things a lot easier if they can just pull it from the session. But I always feel a little bit ''dirty'' in doing so. How do others handle these sorts of things? -George --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
George Bailey wrote:> For instance, I have report that allows all sorts of changes by the > user. He can set filters on the data, sort it in different ways, and > so on. Different Actions get involved, but each of them needs to see > the underlying data. It makes things a lot easier if they can just > pull it from the session. But I always feel a little bit ''dirty'' in > doing so.This is all off the top of my head... What if you created a Search object. A full-blown Rails model. As your users customized their query options, you saved the changes just like any other model. This way you''d also be able to recall a person''s preferences later. Then, in session, you can simply store the ID of that person''s search preferences. Just a thought... - Daniel -- 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 -~----------~----~----~----~------~----~------~--~---
This is exactly my approach, and I''m working on extracting a plugin that deals with the find options extraction automatically. Aside from being able to easily persist to the database, it also makes search forms a snap. See my writeup at: http://darwinweb.net/article/Implementing_Advanced_Search_In_Rails_Using_Search_Models The idea is still somewhat rough in that article, but by the time I get the plugin done it should be much cleaner to implement. On Jun 13, 4:01 pm, Daniel Waite <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> George Bailey wrote: > > For instance, I have report that allows all sorts of changes by the > > user. He can set filters on the data, sort it in different ways, and > > so on. Different Actions get involved, but each of them needs to see > > the underlying data. It makes things a lot easier if they can just > > pull it from the session. But I always feel a little bit ''dirty'' in > > doing so. > > This is all off the top of my head... > > What if you created a Search object. A full-blown Rails model. As your > users customized their query options, you saved the changes just like > any other model. This way you''d also be able to recall a person''s > preferences later. > > Then, in session, you can simply store the ID of that person''s search > preferences. > > Just a thought... > > - Daniel > > -- > 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 -~----------~----~----~----~------~----~------~--~---
dasil003 wrote:> This is exactly my approach...Sweet! I''ve actually been thinking about such a solution for quite some time (I just don''t do it because none of my projects are search intensive). I wish you the best of luck Dasil -- keep us informed of your progress. :) -- 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 -~----------~----~----~----~------~----~------~--~---