This is happening in Rails 3.0.7 and 3.0.9, WEBrick and Apache.
I have a module Reportable
that has a method that writes an inheritable_attribute
:
module Reportable
module ClassMethods
def add_report(report_name)
instance_eval do
write_inheritable_hash(:reportable_report_names,
{report_name => {:dates => true, :details => 'something'})
end
end
end
end
def self.included(base)
base.extend(ClassMethods)
end
end
Reportable
is loaded in config/initializers
and a class uses it:
class User < ActiveRecord::Base
include Reportable
add_report :report1
add_report :report2
end
In production mode, the first time I load a page after the server starts, the attribute loads correctly:
User.read_inheritable_attribute(:reportable_report_names)
# => {:report1 => {:dates => true, :details => 'something'},
:report2 => {:dates => true, :details => 'something'}}
But on the second page load:
User.read_inheritable_attribute(:reportable_report_names)
# => {:report1 => {:dates => true},
:report2 => {:dates => true}}
It works as expected in development, and in the console in production mode. The problem only appears in a POST request on the web server in production mode. What gives?