I thought it would be perfect too, but there's a slight problem. The
limitation is that that form assumes everything as AND'ed. This is
what I came up with yesterday:

@tickets  = Ticket.find :all, :conditions => [
          "((assignee_id IS NULL AND reporter_id = :reporter_id) OR
assignee_id = :assignee_id)
            AND tickets.status_id IN(:statuses) AND
tickets.component_id IN(:components)",
            {
              :assignee_id => user.id,
              :reporter_id => user.id,
              :statuses    => @filter_statuses,
              :components  => @filter_components
            }
          ]

See that OR? I think because of it I can't use the suggested by
Frederick form. And with the form presented here, I couldn't say
tickets.component_id = :components. Rails didn't transform the equal
sign into an "IN" although it did translate the array of component ids
into a comma separated list. But it works nonetheless if I put IN
inside the string. Then, if components are empty, it correctly
replaces the variable with a NULL. And I think everything is properly
escaped as well.
--~--~---------~--~----~------------~-------~--~----~
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