#10 ✓resolved
Georg Ledermann

BUG: Breaking compatibility

Reported by Georg Ledermann | October 15th, 2008 @ 04:02 PM

Some of the last commits of searchgasm breaks compatibility to at least one other plugin. I'm using the very simple plugin "rails-settings" (http://github.com/Squeegy/rails-..., which is not working anymore. This plugin is based on "method_missing" which now results in an endless loop.

First investigations result that your changes in ActiveRecord::Base are causing the problem.

To reproduce:

1) Install "rails-settings" in some application 2) script/console 3) Settings.foo => SystemStackError: stack level too deep

This plugin is not important and maybe it has a bad coded "method_missing", but breaking compatiblity to some other plugins should be avoided, IMHO.

Comments and changes to this ticket

  • Ben Johnson

    Ben Johnson October 15th, 2008 @ 04:34 PM

    • State changed from “new” to “open”

    This is really strange. If I can get this to work properly I can solve the issue. Any ideas?

    >> User.send(:merge_joins, "one", "two")
    => ["one", "two"]
    >> User.respond_to?(:merge_joins)
    => false

    That should return true.

  • Ben Johnson

    Ben Johnson October 15th, 2008 @ 05:28 PM

    • State changed from “open” to “resolved”

    I got this fixed, apparently ActiveRecord changes the default behavior of respond_to?, the second option allows you to include private methods.

    Anyways, this should be fixed now.

  • Georg Ledermann

    Georg Ledermann October 15th, 2008 @ 06:21 PM

    For me it seems the bug is still there. I have tested your latest commit with the rails-settings plugin, which includes this "method_missing":

    class Settings < ActiveRecord::Base
      def self.method_missing(method, *args)
        method_name = method.to_s
        super(method, *args)
      rescue NoMethodError
        #set a value for a variable
        if method_name =~ /=$/
          var_name = method_name.gsub('=', '')
          value = args.first
          self[var_name] = value
        #retrieve a value

    Perhaps this code smells, because the model "Settings" responds to everything, but didn't define a "respond_to?" method.

    I don't know if it's worth to fix compatibility issues regarding every plugin. But because this plugin works without searchgasm (and not with searchgasm), I think this can be cause other plugins to fail.

  • Ben Johnson

    Ben Johnson October 15th, 2008 @ 06:37 PM

    • State changed from “resolved” to “open”

    Are you sure you are using the latest searchgasm?

    I just ran some tests:

    >> Settings.awesome
    => nil

    And it works fine. What rails version are you using?

  • Georg Ledermann

    Georg Ledermann October 16th, 2008 @ 03:01 AM

    Strange, you are right, it works fine with plain Rails (2.1.1) and just this plugin (tested with new created Rails app). In my existing application there are a some more plugins in use. I will do some further tests to see which combination of plugins breaks it.

  • Georg Ledermann

    Georg Ledermann October 16th, 2008 @ 10:13 AM

    After a few hours of debugging I give up :( In a plain new Rails app the StackOverflow does not occur, but in my large application it does (on calling "Settings.foo"). I have copied all plugins, gems, initializers and same more to the plain app, but in this dummy app it all works. I can't extract the problem.

    I will come back later to this ticket if I can reproduce it...

  • Ben Johnson

    Ben Johnson October 16th, 2008 @ 10:31 AM

    I am certain I could easily fix the issue. I am betting it has to do with your version of ActiveRecord. Are you using the same version of rails?

    I want to solve the problem because something isn't right. I am leaving ot go on vacation and will return Sunday. If you have skype or anything, maybe we can get together on that and try to debug it together. I am certain we can solve the issue quickly. Something like this, where I can't reproduce the problem, would take forever talking through this.

    What was the problem before we the add_joins method in searchgasm/active_record/base.rb. That function was calling a method that didn't exist, which then called method_missing in Settings.rb. Settings.rb called add_joins again, and it got caught in an infinit loop. Settings.rb called add_joins becuase it is trying to execute a query. I have a feeling the problem lies somewhere in add_joins. Also, add_joins is just copied over from ActiveRecord with my own modifications. You will notice there are 2 versions and I do checks to determine which version of code to run. Since add_joins has changed quite a bit in the last few versions of rails.

  • Georg Ledermann

    Georg Ledermann October 16th, 2008 @ 11:40 AM

    Argh, shame on me, it was my fault:

    I made some modifications to the plugin "rails-settings" (including renamings of the database fields) and replaced the plugin (by mistake) with the original from github, so the method "Settings.find_by_var" did not work anymore because of the missing field "var" in the database. So the method_missing was called in an endless loop. It has nothing to to with searchgasm (except I made this nearly the same time I upgraded searchgasm).

    In my dummy app the original plugin and original database structure were matching, so all went fine in this app.

    Thank you for your commitment, I hope my future bug reports will not be such false alarm ;-)

    Note to myself: Never ever change plugins from other people without creating a fork on github.

  • Ben Johnson

    Ben Johnson October 16th, 2008 @ 04:11 PM

    • State changed from “open” to “resolved”

    Not a problem at all, glad you figured out what the issue was. Let me know if you have any other problems.

  • reena smith
  • Pak24tv

    Pak24tv December 9th, 2020 @ 01:16 AM

    I am happy to find your distinguished way of writing the post. Now you make it easy for me to understand and implement the concept. Thank you for the post. jazz daily call packages jazz monthly sms packages

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Provides common named scopes and object based searching.

People watching this ticket

Referenced by