rubinius/rubinius — Issue #1341: Inconsistent look-up of constants
Author: cordawyn
Created: 2011-10-23 08:12:45+00:00
State: open

The original issue: https://github.com/resolve/refinerycms/issues/1092

I'm running RefineryCMS (1.0.8, rails-3.0.10) with Rubinius (rbx-1.2.4-20110705). When I open a RefineryCMS page, I'm getting error:

TypeError (wrong argument type NilClass (expected Module))

I managed to track it down to refinerycms-core-1.0.8/lib/refinery/application_controller.rb (abridged):

module Refinery
module ApplicationController
def self.included(controller)
controller.send :include, ::Refinery::ApplicationController::ClassMethods
end
module ClassMethods
def self.included(c)
c.send :include, Crud # basic create, read, update and delete methods
end
end
end
end

"Crud" module is defined in refinerycms-core-1.0.8/lib/refinery/crud.rb (abridged):

module Refinery
module Crud
...
end
end

Apparently, Rubinius fails to look-up "Crud" in a very peculiar way. Changing the line to use a "fully qualified" constant name fixes the problem:

c.send :include, ::Refinery::Crud # basic create, read, update and delete methods

I suspect this is also a thread-related issue, because this line works fine without the fix... only once. When I reload a successfully rendered page (and thus start another thread in Rails), the error appears. Or maybe it's the class reloading in Rails (in development mode).
Speaking of which, a RefineryCMS project won't run in production mode at all:

$ RAILS_ENV=production bundle exec rails s

Thread deadlock in ::lock()!
Aborted

...but that's a different issue.