hi, is there a elegant way to do non-keyword searches with incremental criteria? for instance a search for a users with option to select criterias like gender, age, profession from pulldowns and checkboxes. with php I would build the sql query going through a bunch of conditionals... I could do the same with rails I suppose, but I''m wondering if there''s an smart rails solution for this kind of search? thanks Oliver
Not sure what exactly you mean - do you know about find_by_<attribute>? On 01/09/05, oliver barnes <ol1barn3s-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> hi, > is there a elegant way to do non-keyword searches with incremental > criteria? for instance a search for a users with option to select > criterias like gender, age, profession from pulldowns and checkboxes. > > with php I would build the sql query going through a bunch of > conditionals... I could do the same with rails I suppose, but I''m > wondering if there''s an smart rails solution for this kind of search? > > thanks > Oliver > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Rasputin :: Jack of All Trades - Master of Nuns
i''m reading up on it right now... my question regarding it is, when an attribute isn''t selected, does the find_by_attribute regard it as a "select where attribute is null"? thanks oliver On Sep 2, 2005, at 8:34 AM, Dick Davies wrote:> Not sure what exactly you mean - > do you know about find_by_<attribute>? > > On 01/09/05, oliver barnes <ol1barn3s-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> hi, >> is there a elegant way to do non-keyword searches with incremental >> criteria? for instance a search for a users with option to select >> criterias like gender, age, profession from pulldowns and checkboxes. >> >> with php I would build the sql query going through a bunch of >> conditionals... I could do the same with rails I suppose, but I''m >> wondering if there''s an smart rails solution for this kind of search? >> >> thanks >> Oliver >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> >> > > > -- > Rasputin :: Jack of All Trades - Master of Nuns > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Your code should handle null selections gracefully and supply defaults for the find_by_attribute if you want them. On 9/3/05, oliver barnes <ol1barn3s-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > i''m reading up on it right now... my question regarding it is, when > an attribute isn''t selected, does the find_by_attribute regard it as > a "select where attribute is null"? > thanks > oliver > On Sep 2, 2005, at 8:34 AM, Dick Davies wrote: > > > Not sure what exactly you mean - > > do you know about find_by_<attribute>? > > > > On 01/09/05, oliver barnes <ol1barn3s-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > >> hi, > >> is there a elegant way to do non-keyword searches with incremental > >> criteria? for instance a search for a users with option to select > >> criterias like gender, age, profession from pulldowns and checkboxes. > >> > >> with php I would build the sql query going through a bunch of > >> conditionals... I could do the same with rails I suppose, but I''m > >> wondering if there''s an smart rails solution for this kind of search? > >> > >> thanks > >> Oliver > >> _______________________________________________ > >> Rails mailing list > >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > >> http://lists.rubyonrails.org/mailman/listinfo/rails > >> > >> > > > > > > -- > > Rasputin :: Jack of All Trades - Master of Nuns > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
hi patrick, sorry, I''m not following you... what kind of defaults would I use so that ''find_by'' would look for any result of that attribute? could you send an example? I''ll try to rephrase it, not sure i expressed myself well the first time... say I have a form which gives the option to search for a person by age, gender and/or eyecolor. to handle the search, I use: find_by_age_and_gender_and_eyecolor what happens when on the form only gender is selected? does the find method interpret it as: find_by_gender (thus ignoring the other attributes) or does it interpret the missing attributes as NULL values? Oliver On Sep 3, 2005, at 8:38 AM, Patrick McCafferty wrote:> Your code should handle null selections gracefully and supply > defaults for the find_by_attribute if you want them. > > On 9/3/05, oliver barnes < ol1barn3s-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:i''m reading > up on it right now... my question regarding it is, when > an attribute isn''t selected, does the find_by_attribute regard it as > a "select where attribute is null"? > thanks > oliver > On Sep 2, 2005, at 8:34 AM, Dick Davies wrote: > > > Not sure what exactly you mean - > > do you know about find_by_<attribute>? > > > > On 01/09/05, oliver barnes <ol1barn3s-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > >> hi, > >> is there a elegant way to do non-keyword searches with incremental > >> criteria? for instance a search for a users with option to select > >> criterias like gender, age, profession from pulldowns and > checkboxes. > >> > >> with php I would build the sql query going through a bunch of > >> conditionals... I could do the same with rails I suppose, but I''m > >> wondering if there''s an smart rails solution for this kind of > search? > >> > >> thanks > >> Oliver > >> _______________________________________________ > >> Rails mailing list > >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > >> http://lists.rubyonrails.org/mailman/listinfo/rails > >> > >> > > > > > > -- > > Rasputin :: Jack of All Trades - Master of Nuns > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >