undefined method ‘guard_condition’ when using subdomain_fu on Rails 2.2

Posted by andy gaskell on Dec 31st, 2008

frank and charlieWhile working with subdomain_fu I was having some issues with routes and it was suggested in the railscasts comments that installing from the plugin was different than the gem.

keyJ says:

I found that I makes a difference whether you install it as a plugin (from github) or a gem. With the gem I could not get the route to accept the :subdomain-condition correctly. But then I installed the plugin with ./script/plugin install…
and all of a sudden it worked fine.

This got me a step closer. When I restarted Apache I got this error message:
undefined method `guard_condition' for class `ActionController::Routing::Optimisation::PositionalArgumentsWithAdditionalParams'

I eventually figured out that this code was added a couple months ago – I removed the code referenced in the blog post and now my routing issues are resolved.

One Response

  1. Christopher Says:

    After looking at the optimizations.rb, I figured out, that rails changed the method name of guard_condition to guard_conditions with an array as return value opposed to the string used before.

    So I think this code should do the job:

    module Routing
    module Optimisation
    class PositionalArgumentsWithAdditionalParams
    def guard_conditions_with_subdomains guard_conditions_without_subdomains << "!args.last.has_key?(:subdomain)"
    end

    alias_method_chain :guard_conditions, :subdomains
    end
    end
    end

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.