Hi,
I have a named_scope that retrieves all the products for the current website based on its domain name:
Hi,
I have a named_scope that retrieves all the products for the current website based on its domain name:
I solved it by appending the first method to the chain.
I have another problem:
I want to chain 2 named_scopes that both have a :joins in their definition. The problem is that the :joins of the second named_scope in the chain doesn't get added to the query. IS that normal behavior?
Fernando Perez wrote:
I solved it by appending the first method to the chain.
I have another problem:
I want to chain 2 named_scopes that both have a :joins in their definition. The problem is that the :joins of the second named_scope in the chain doesn't get added to the query. IS that normal behavior?
I solved that problem too, it was again the select(*) that was getting in the way.
Now another question: can I chain 2 named_scopes that define the :joins option? Is named_scope smart enough to append the two :joins like it does for :conditions? I can't make it happen. Only one of the :joins finds its way in the final query sent to the DB.
Actually chaining 2 named_scopes that have :joins in them is not yet possible as of Rails 2.1.1, the issue is fixed and is available in Rails edge, or we'll have to wait until 2.2 is out.