Yeah, that helps a lot. I actually realized that a little bit after posting and looked it up on Google, but this confirms it. Thanks!
On May 15, 9:19 am, Marnen Laibow-Koser <[email protected]> wrote: > On May 14, 4:28 pm, Mike C <[email protected]> wrote: > > > I have a Search Model which contains search data. It looks like this: > > > keywords:string > > by_user:boolean > > by_title:boolean > [...] > > def find_stories > > find(:all, :conditions => ??) > > end > > > I'm confused has to how to make the conditions since it will have to > > check which booleans are true and then append onto the conditions. How > > would I do this? > > Remember, :conditions can take a hash, which means you can do what you > want if you get your head out of ActiveRecord for a minute and into > Ruby hash-munging. :) So for example: > > def find_stories(by_user = false, by_title = false) > conditions = {} > conditions[:user] = 'some criteria' if by_user > conditions[:title] = 'more criteria' if by_title > Story.find(:all, :conditions => conditions.merge(:any => > 'other', :options => 'you want') > end > > Does that help? > > Best, > -- > Marnen Laibow-Koserhttp://www.marnen.org > [email protected] --~--~---------~--~----~------------~-------~--~----~ 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

