On Apr 29, 10:28 pm, slava <[email protected]> wrote:
> Hello,
> I am trying to construct a lookup based on params submited.
> possible urls..
> /gadgets?product_id=1
> /gadgets?product_id=1&product_group_id=2
> /gadgets?product_location_id=5
> /gadgets?product_id=1&product_location=5
> ...
>
> How do I write a universal lookup method ?
>
You may find that the hash form of :conditions is the easiest way to
do this.

Fred
> Gadget.find_by_product_id
> Gadget.find_by_product_id_and_product_group_id
> Gadget.find_by_product_location_id
> Gadget.find_by_product_id&product_location_id
>
> I want find_by... to include only submitted params from a set of
> possible options.
>
> Essentially I want find a way to avoid writing many if and else and
> wonder if anyone knows an easier and better approach.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to