Re: [Rails] Chain scopes with OR

2012-05-22 Thread Gustavo de Sá Carvalho Honorato
@Rogerio: This way the scopes are merged with AND not OR @Jeremy: I've read README and I haven't found a way to join scopes with OR, as you mentioned. The only way I found is to join attributes with OR, not scopes. I've tried that hack (where_clauses.join('OR')) before too. The problem is that,

Re: [Rails] Chain scopes with OR

2012-05-22 Thread azizmb.in
Hi Gustavo Coincidentally, I was recently doing something similar. Older versions of rails used to evaluate my previous solution using | to an ActiveRelation. When this stopped I dont know, or maybe I am just mistaken. In any case, I finally settled on using the squeel

Re: [Rails] Chain scopes with OR

2012-05-22 Thread Rogerio Medeiros
U try ? escopo: find_visibles, lambda { find_in_coverage|find_know_ missing} 2012/5/22 azizmb.in m...@azizmb.in Hi Gustavo Coincidentally, I was recently doing something similar. Older versions of rails used to evaluate my previous solution using | to an ActiveRelation. When this

Re: [Rails] Chain scopes with OR

2012-05-21 Thread Gustavo de Sá Carvalho Honorato
The problem of the first solution is that find_in_coverage | find_known_missing combined that way does not return a scope. It returns two arrays each and applies | operator on the result. See: http://www.ruby-doc.org/core-1.9.3/Array.html#method-i-7C I've looked arel docs (in fact, I just found

Re: [Rails] Chain scopes with OR

2012-05-21 Thread Jeremy Walker
On 22 May 2012 01:58, Gustavo de Sá Carvalho Honorato gustavohonor...@gmail.com wrote: The problem of the first solution is that find_in_coverage | find_known_missing combined that way does not return a scope. It returns two arrays each and applies | operator on the result. See:

Re: [Rails] Chain scopes with OR

2012-05-21 Thread Rogerio Medeiros
try escopo: find_visibles, lambda { find_in_coverage.find_know_missing} 2012/5/21 Gustavo de Sá Carvalho Honorato gustavohonor...@gmail.com The problem of the first solution is that find_in_coverage | find_known_missing combined that way does not return a scope. It returns two arrays each

[Rails] Chain scopes with OR

2012-05-18 Thread Gustavo de Sá Carvalho Honorato
Hi all! I've googled all over and I couldn't find anything about chaining scopes with OR instead of the default AND. I have an Asset model with the following scopes: class Asset ActiveRecord::Base (...) scope :find_in_coverage, lambda { where('timestamp(assets.found_at) = ?',

Re: [Rails] Chain scopes with OR

2012-05-18 Thread azizmb.in
AFAIK, something like this should work: def find_visibles find_in_coverage | find_known_missing end On Fri, May 18, 2012 at 10:53 PM, Gustavo de Sá Carvalho Honorato gustavohonor...@gmail.com wrote: Hi all! I've googled all over and I couldn't find anything about chaining scopes with

Re: [Rails] Chain scopes with OR

2012-05-18 Thread azizmb.in
To add to that, if you want to construct complex queries, you should have a look at arel https://github.com/rails/arel. On Sat, May 19, 2012 at 12:17 AM, azizmb.in m...@azizmb.in wrote: AFAIK, something like this should work: def find_visibles find_in_coverage | find_known_missing end