title: Searchlogic: how do I define a namedscope so that I can use OR on an associated model?
body: <p>So, I found this: <a href="https://stackoverflow.com/questions/5877439/searchlogic-or-condition-results-in-undefined-method">Searchlogic OR condition results in undefined method</a></p>
  
  <p>But that only works for fields on the model your are searching on directly.
  I have a suscription model, but I want to search over the different subscriptions' account names OR their other_field, for example.</p>
  
  <p>from the above link (and modified) I'd like to be able to do something similar to this: </p>
  
  <pre><code>  named_scope :account_name_full_domain_like, lambda{ |name|{
       :conditions =&gt; ["accounts.name LIKE ? OR accounts.full_domain LIKE ?", "%" + name + "%", "%" + name + "%"],
       :joins =&gt; "LEFT JOIN `accounts` ON `accounts`.id = `subscriptions`.account_id"
      }}
  </code></pre>
  
  <p>but now I get an error on this:</p>
  
  <pre><code>27:     &lt;% form_for @search do |f| %&gt;  
  
  undefined method `subscription_subscription_path' for #&lt;ActionView::Base:0x11061dbc0&gt;
  </code></pre>
  
  <p>EDIT:
  figured it out:
  had to include .search in my call for assignment of the @search var</p>
  
  <pre><code>@search = Subscription.search.account_name_full_domain_like(term)
  </code></pre>