Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8005125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:08:09+00:00 2026-06-04T17:08:09+00:00

I’m using active_admin and that’s bringing in meta_search to my project. (Which I don’t

  • 0

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).

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.

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.

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.

EDIT: I don’t know of a good way of including code blocks in answers to answers, so I’ll put this here.

# Meta_search loaded, tire is not
1.9.3p125 :001 > require "tire"   #=> true
1.9.3p125 :002 > Document.send(:include, Tire::Model::Search)
=> Document(...)
1.9.3p125 :003 > 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 > Document.search
# I get tire, as I should
1.9.3p125 :002 > require "meta_search"   #=> true
1.9.3p125 :003 > Document.search
# I still get tire, all is well

# Tire loaded, meta_search is not loaded
1.9.3p125 :001 > require "meta_search"   #=> true
1.9.3p125 :002 > 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 > require "meta_search"
=> true 
1.9.3p125 :002 > Document.search
# I get tire!

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T17:08:11+00:00Added an answer on June 4, 2026 at 5:08 pm

    the relevant 2 lines:

    https://github.com/ernie/meta_search/blob/master/lib/meta_search.rb#L55

    https://github.com/ernie/meta_search/blob/master/lib/meta_search/searches/active_record.rb#L46

    I don’t think it is a bug, it is just how things are.

    in scenario 3 In development environment, you do not preload the model. When you require ‘meta_search’, it will define ‘search’ on ActiveRecord::Base. Then you say Document, which loads the model, will first inherit defined search method so when it includes Tire search module, it will leave search aliased to metasearch.

    In production mode (scenario 4) as well as scenario 2, you preload the document model before metasearch so Tire will define search. Now requiring metasearch will only have effect on newly loaded classes.

    You can see that the order in which gems are defined does not count. But you can undefine search method after gem require.

    # application.rb
    # ...
    Bundler.require(:default, Rails.env) if defined?(Bundler)
    # now move search out of the way
    ActiveRecord::Base.instance_eval { undef :search }
    

    so any time later we load a model class and include tire, search will correctly go to tire, both in development and production.

    This is not ideal since the search method for non-tire models will not delegate to metasearch, in fact it will not be defined. So probably the second solution is best: here you overwrite the search method with one which checks for tire at runtime:

    class ActiveRecord::Base
      def self.search(*args, &block)
        if respond_to?(:tire)
           tire.search(*args, &block)
        else
           metasearch(*args, &block)
        end
      end
    end
    

    does this help?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I want use html5's new tag to play a wav file (currently only supported
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I used javascript for loading a picture on my website depending on which small
I am reading a book about Javascript and jQuery and using one of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.