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

Closed
deathbob opened this Issue Oct 1, 2012 · 4 comments

Comments

Projects
None yet
5 participants
@deathbob

deathbob commented Oct 1, 2012

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

This comment has been minimized.

Show comment Hide comment
@clee704

clee704 Oct 11, 2012

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.

clee704 commented Oct 11, 2012

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

This comment has been minimized.

Show comment Hide comment
@nevinng

nevinng Oct 11, 2012

I am seeing similar error as well:

config.ru:26:in `block in

': uninitialized constant HttpAcceptLanguage::Middleware (NameError)

nevinng commented Oct 11, 2012

I am seeing similar error as well:

config.ru:26:in `block in

': uninitialized constant HttpAcceptLanguage::Middleware (NameError)

@cjbell

This comment has been minimized.

Show comment Hide comment
@cjbell

cjbell Oct 11, 2012

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

cjbell commented Oct 11, 2012

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

@clee704

This comment has been minimized.

Show comment Hide comment
@clee704

clee704 Oct 12, 2012

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

clee704 commented Oct 12, 2012

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment