Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uninitialized constant RoutingFilter::Filter #27

Closed
nshbrown opened this issue May 22, 2011 · 4 comments
Closed

uninitialized constant RoutingFilter::Filter #27

nshbrown opened this issue May 22, 2011 · 4 comments

Comments

@nshbrown
Copy link

When I use bundler with the latest code on rails 2.3.11 it gives me the following error.

Here is my sample filter /lib/routing_filter.rb:

module RoutingFilter
  class Country < Filter
    # remove the locale from the beginning of the path, pass the path
    # to the given block and set it to the resulting params hash
    def around_recognize(path, env, &block)
      country = nil
      path.sub! %r(^/(italy|france|spain)(?=/|$)) do country = $1; '' end
      returning yield do |params|
        params[:country] = country || 'italy'
      end
    end

    def around_generate(*args, &block)
      country = args.extract_options!.delete(:country) || 'italy'
      returning yield do |result|
        if country != 'italy'
          result.sub!(%r(^(http.?://[^/]*)?(.*))){ "#{$1}/#{country}#{$2}" }
        end 
      end
    end

  end
end

And my /config/routes.rb:

ActionController::Routing::Routes.draw do |main|
  filter :country
end
@mjonuschat
Copy link
Collaborator

Did you try adding

require 'routing_filter'

or maybe just

require 'routing_filter/filter'

before defining your Country filter?

@mykola-kyryk
Copy link

Requiring 'routing_filter' doesn't resolve the issue for me. Any ideas?

@mjonuschat
Copy link
Collaborator

I'm pretty sure it has something to do with your app or the load paths. I just created a new rails 2.3.14 app, took the country filter from a few comments above, stuck it into lib/routing_filter/country.rb and could use it in the routes file without any error.

@mjonuschat
Copy link
Collaborator

Works on 3.1.4 and 3.2.3 as well, closing this as it's not reproducible. Please re-open if there is a documented way to show this error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants