Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I stop meta_search from defining search on my models?
    primarykey
    data
    text
    <p>I'm using active_admin and that's bringing in meta_search to my project. (Which I don't want to use for anything else).</p> <p>It seems to be defining the search method on all my models, which then means when I include tire, I can't use it's search method.</p> <p>There seems to be something strange with how it's defining the method also - method_defined? says that the search method is not defined, yet when I call it I get the meta_search one. Even if I define my own search method in the class, when I call Document.search I still get meta_search.</p> <p>EDIT: I'd be interested in general ways of dealing with this sort of thing - I have solved this particular issue by using Model.tire.search (since tire is also accessible that way), but I still hate that a gem I'm not even using can force me to use a workaround in the rest of my project.</p> <p>EDIT: I don't know of a good way of including code blocks in answers to answers, so I'll put this here.</p> <pre><code># Meta_search loaded, tire is not 1.9.3p125 :001 &gt; require "tire" #=&gt; true 1.9.3p125 :002 &gt; Document.send(:include, Tire::Model::Search) =&gt; Document(...) 1.9.3p125 :003 &gt; Document.search Document Load (2.1ms) SELECT "documents".* FROM "documents" # I get meta_search, as I should # Tire loaded (and the include Tire::Model::Search is inside the class definition), meta_search is not loaded 1.9.3p125 :001 &gt; Document.search # I get tire, as I should 1.9.3p125 :002 &gt; require "meta_search" #=&gt; true 1.9.3p125 :003 &gt; Document.search # I still get tire, all is well # Tire loaded, meta_search is not loaded 1.9.3p125 :001 &gt; require "meta_search" #=&gt; true 1.9.3p125 :002 &gt; Document.search Document Load (1.8ms) SELECT "documents".* FROM "documents" # I get meta_search, even though Document.search was already defined! # Tire loaded, meta_search is not loaded, RAILS_ENV="production" Loading production environment (Rails 3.2.2) 1.9.3p125 :001 &gt; require "meta_search" =&gt; true 1.9.3p125 :002 &gt; Document.search # I get tire! </code></pre> <p>My interpretation of this is that there is a bug with how meta_search detects if search is already defined when the class hasn't actually loaded. Hooray!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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