0

I'm developing a Rails 3 Engine for one of our projects. To debug an issue I moved the gem declaration to a :path statement, as the edge guide suggests. It comes about two gems after the requirement for the aws-s3 gem. Now, when I try to start up the development server using rails s, I get an error from aws-s3 that looks like this:

/Users/me/.rvm/gems/ruby-1.9.3-p194@xproject/gems/aws-s3-0.6.3/lib/aws/s3/extensions.rb:212:in `const_missing_from_s3_library': uninitialized constant MyEngineNamespace::Engine (NameError)

The associated bit of code in the S3 gem looks like this:

def const_missing_from_s3_library(sym)
  if sym.to_s =~ /^(\w+)(Bucket|S3Object)$/
    const = const_set(sym, Class.new(AWS::S3.const_get($2)))
    const.current_bucket = $1.underscore
    const
  else
    const_missing_not_from_s3_library(sym)
  end
end
alias_method :const_missing_not_from_s3_library, :const_missing
alias_method :const_missing, :const_missing_from_s3_library

But I'm not at all sure why this code got called; the engine doesn't (intentionally) touch S3. So... huh?

pjmorse
  • 9,204
  • 9
  • 54
  • 124

2 Answers2

2

Not 100 % an answer to your question, but it will in a way solve your problem:

It's recommended to use fog instead of aws-s3, which isn't threadsafe among other things according to the Sidekiq wiki. Fog is a lot more flexible in terms which cloud services to access and actively supported. Here's a good guide for getting started with Fog and S3.

Thomas Klemm
  • 10,678
  • 1
  • 51
  • 54
  • That's probably not a bad idea... but I'm already [taking quite a bit of hair off this yak](http://www.catb.org/jargon/html/Y/yak-shaving.html). Seems like there should be a lighter solution to the problem. – pjmorse Sep 26 '12 at 18:00
  • Cool dictum, I'll have to remember that. – Thomas Klemm Sep 26 '12 at 18:48
1

Ah. Figured it out. The issue wasn't S3 (as I suspected) but the way I was including the engine in the Gemfile, which I didn't include in the question (so no wonder nobody figured it out).

This works:

gem "my_engine", :path => "/Users/me/Projects/my-engine", :require => 'my-engine'

This doesn't:

gem "my_engine", :path => "/Users/me/Projects/my-engine"

The :require parameter seems to be useful in setting up the constants.

pjmorse
  • 9,204
  • 9
  • 54
  • 124