First Call to a Controller, Constant is defined, Second call, "uninitialized constant Oauth"?

Posted by viatropos on Stack Overflow See other posts from Stack Overflow or by viatropos
Published on 2010-05-09T03:05:18Z Indexed on 2010/05/09 3:08 UTC
Read the original article Hit count: 335

I am trying to get the OAuth gem to work with Rails 3 and I'm running into this weird problem... (independent of the gem, I think I've run into this once before)

I have a controller called "OauthTestController", and a model called "ConsumerToken". The model looks like this.

require 'oauth/models/consumers/token'
class ConsumerToken < ActiveRecord::Base
  include Oauth::Models::Consumers::Token
end

When I go to "/oauth_test/twitter", it loads the Oauth::Models::Consumers::Token module and I'm able to connect to twitter no problem. But the second time I try it (just refresh the /oauth_test/twitter url), it gives me this error:

NameError (uninitialized constant Oauth):
  app/models/consumer_token.rb:4
  app/models/twitter_token.rb:2
  app/controllers/oauth_test_controller.rb:66:in `load_consumer'

Why is that? It has something to do with load paths or being in development mode maybe?

© Stack Overflow or respective owner

Related posts about rails

Related posts about uninitialized-constant