Am 04.07.2009 um 19:11 schrieb Matt Jones:
> Assuming that Client has_many Hosts, you could do: Yes, it has. > client_hosts = options[:client] ? Client.find(options > [:client]).hosts : Host > old_hosts = client_hosts.last_seen_before((minutes.minutes.ago) That still leaves me with a ? : construct, which in my eyes should be useless. Anyway, thanks Marnen and Matt for the suggestions, but I've gone with the scope chaining mentioned in another post a little earlier on the list. For the record, the result is: """ minutes = options[:minutes] || 10 client_id = options[:client] ? Client.find(options[:client]) : nil old_hosts = Host.last_seen_before(minutes.to_i.minutes.ago) old_hosts = old_hosts.find_all_by_client_id(client_id) unless client_id.nil? """ For the next options/scopes, I can just continue to do 'old_hosts = old_hosts.other_scope(some_param) unless some_param.nil?' to further chain the scopes and thus narrow the list of results as needed. Regards, Felix --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

