Note that there are some explanatory texts on larger screens.

plurals
  1. POMetaSearch Gem - Rails 3.0 working scope methods fail in Rails 3.2
    text
    copied!<p>MetaSearch's handy functions such as .not_in worked in Rails 3.0 &amp; 3.1 inside of scope calls.</p> <p>I had to rewrite some scopes to be "plain Rails 3.2" without MetaSearch convenience even though MetaSearch works outside of scope. And it broke several of my apps &amp; tools when I upgraded.</p> <p>Ideas? I am using MetaSearch everywhere. Even wrote a custom predicate. Still could be missing something obvious I hope.</p> <p>On Rails 3.2, working inside an engine for code separation. Didn't seem to matter when I tried to isolate to Vanilla-Rails with no namespace/subfolders or engines.</p> <p>Note -- I just wrote my first customized "Where" predicate :gt_da for :greater_than_days_ago so :created_gt_da = 7 will search for records created >= 7.days.ago <a href="https://github.com/ernie/meta_search/wiki/Handy-way-to-develop-and-test-creating-a-new-%22Where%22-without-restarting-your-server-everytime" rel="nofollow">https://github.com/ernie/meta_search/wiki/Handy-way-to-develop-and-test-creating-a-new-%22Where%22-without-restarting-your-server-everytime</a></p> <pre><code> class Bug &lt; ActiveRecord::Base # MetaSearch search_methods :bug_active ## Rails 3.0 (and gems of that time) =&gt; 100%), 3.1 pretty sure ## Rails 3.2 error: "undefined method `not_in' for :resolution:Symbol" scope :bug_active, lambda {|checked| where(:resolution.not_in =&gt; ['ERWITHPM','WONTFIX','WORKSFORME','DATAFIXDEPLOYED','PATCHDEPLOYED','RELEASEDEPLOYED','DUPLICATE','INVALID'] \ , :bug_status.not_in =&gt; ['VERIFIED'] ) } ## Rewritten to work in Rails 3.2 without MetaSearch convenience inside of scope ## ... a pinch more work which is why we love MetaSearch! scope :bug_active_why, lambda {|checked| where("resolution not in (?)", ['ERWITHPM','WONTFIX','WORKSFORME','DATAFIXDEPLOYED','PATCHDEPLOYED','RELEASEDEPLOYED','DUPLICATE','INVALID']) .where("bug_status not in (?)", ['VERIFIED'] ) } end module Bugzilla class BugsController &lt; ApplicationController @p = params[:search] ## MetaSearch works fine here on ":resolution_not_in" from form/search @p[:resolution_not_in] = ['WONTFIX','WORKSFORME'] @search = Bug .limit(50) .where("version like '2012_%p'") .search(@p) end end </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload