Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

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

Closed
deathbob opened this Issue · 4 comments

5 participants

@deathbob

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 0.0.0.0:3000, CTRL+C to stop
[51, 60] in /Users/lovebob/src/cardagin-web/app/controllers/application_controller.rb
   51  
   52    protected
   53  
   54    def set_locale
   55      debugger
=> 56      available = sanitize_available_locales #I18n.available_locales
   57  
   58      http_accept_language.preferred_language_from(available)
   59  
   60      debugger
/Users/lovebob/src/cardagin-web/app/controllers/application_controller.rb:56
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
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 config.ru 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 http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/Users/lovebob/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/ext/module.rb:36:in `const_missing': uninitialized constant HttpAcceptLanguage::Middleware (NameError)
@clee704

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.

@nevinng

I am seeing similar error as well:

config.ru:26:in `block in

': uninitialized constant HttpAcceptLanguage::Middleware (NameError)

@cjbell

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

@clee704

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.