Skip to content


Subversion checkout URL

You can clone with
Download ZIP


NameError Exception in controller when calling methods included from EasyAccess #22

deathbob opened this Issue · 4 comments

5 participants


Hi, I'm trying to use the methods in the controller but getting no_method_error.

Here's what it looks like from inside the controller

>> Listening on, CTRL+C to stop
[51, 60] in /Users/lovebob/src/cardagin-web/app/controllers/application_controller.rb
   52    protected
   54    def set_locale
   55      debugger
=> 56      available = sanitize_available_locales #I18n.available_locales
   58      http_accept_language.preferred_language_from(available)
   60      debugger
available = sanitize_available_locales #I18n.available_locales
(rdb:1) http_accept_language
NameError Exception: undefined local variable or method `http_accept_language' for <ApplicationController:0x007fe2b28c91e0>
(rdb:1) env.http_accept_language
NoMethodError Exception: undefined method `http_accept_language' for <Hash:0x007fe2b2e11670>
(rdb:1) http_accept_language.user_preferred_languages
NameError Exception: undefined local variable or method `http_accept_language' for #<ApplicationController:0x007fe2b28c91e0>
(rdb:1) HttpAcceptLanguage
(rdb:1) HttpAcceptLanguage::Middleware
NameError Exception: uninitialized constant HttpAcceptLanguage::Middleware
(rdb:1) HttpAcceptLanguage::EasyAccess
NameError Exception: uninitialized constant HttpAcceptLanguage::EasyAccess

Really not sure what's going on here, it's like it's not being required correctly?

I just added it to my gemfile and did bundle install.
Ruby can find the top level constant just fine, but when I try and access any of the classes underneath it it blows up.

Any ideas what I could be doing wrong ?

cardagin-web git:spike/i18n ❯ irb                                                                                                                                                                  
1.9.3p194 :001 > require 'http_accept_language'
 => true 
1.9.3p194 :002 > HttpAcceptLanguage
 => HttpAcceptLanguage 
1.9.3p194 :003 > HttpAcceptLanguage::Middleware
NameError: uninitialized constant HttpAcceptLanguage::Middleware
    from (irb):3
    from /Users/lovebob/.rvm/rubies/ruby-1.9.3-p194/bin/irb:16:in `<main>'
1.9.3p194 :004 > HttpAcceptLanguage::EasyAccess
NameError: uninitialized constant HttpAcceptLanguage::EasyAccess
    from (irb):4
    from /Users/lovebob/.rvm/rubies/ruby-1.9.3-p194/bin/irb:16:in `<main>'

Tried adding it to my and that blew up too, with similar results

cardagin-web git:spike/i18n ❯ be rails server                                                                                                                                                      
=> Booting Thin
=> Rails 3.2.8 application starting in development on
=> Call with -d to detach
=> Ctrl-C to shutdown server
/Users/lovebob/.rvm/gems/ruby-1.9.3-p194@global/gems/rake- `const_missing': uninitialized constant HttpAcceptLanguage::Middleware (NameError)

I have a similar issue although I don't know what EasyAccess is. http_accept_language in my application controller raises NameError. Rails 3.2.8 && HttpAcceptLanguage 1.0.2

If more details are needed, I will post an example project to reproduce this issue.


I am seeing similar error as well: `block in

': uninitialized constant HttpAcceptLanguage::Middleware (NameError)


I also have the same issue, running on Rails 3.2.8 with HttpAcceptLanguage 1.0.2


It's been solved in @DouweM's no-middleware-no-crash branch. See #19.

@DouweM DouweM closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.