Re: Re: Creating queries

I don’t even think you need a hidden variable. If
only one value from your condition options shows up in
params, maybe this:

def list
hash = {‘name’=>q2,‘date range’=>q3}
selected_condition = params.keys & hash.keys
condition = hash[selected_condition]

B Gates

Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around

I think this is a good way to do it. One thing that came to my mind
is while building your conditions you may have varying number of
condition arguments. For example the name query has one argument
while a date range will have two. Perhaps some trickery counting ‘?’
in the conditions query could do the trick or maybe a hash with
the key of the query and value being the argument count.

I would also think that defining the possible queries in an array/hash
could be used on the front-end and back-end with consistency and would
allow you to add and remove queries in the future without much more

Good luck!

Thanks Todd & B Gates. Off to coding I go again. I’m sure I’ll
resurface and ask more… :slight_smile:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs