preload_app = true causing - ActiveModel::MissingAttributeError: missing attribute: some_attr

Eric Wong normalperson at
Sun Jan 20 08:04:31 UTC 2013

Avner Cohen <avner.cohen at> wrote:
> Greetings,
> I'm getting this  - ActiveModel::MissingAttributeError: missing
> attribute: some_attr  - on a random basis under a unicorn server,
> running rails 3.2 and ruby 1.9.3
> As the case of the last poster in the following thread -
> -  I too am able to resolve
> this issue by settingpreload_app to false.
> However, this is not the behaviour I want to have.
> Any inputs on that, or data I can provide around this issue?

Did you try disconnecting in your before_fork hook and reconnecting

before_fork do |server, worker|
  # the following is highly recomended for Rails + "preload_app true"
  # as there's no need for the master process to hold a connection
  defined?(ActiveRecord::Base) and

after_fork do |server, worker|
  # the following is *required* for Rails + "preload_app true",
  defined?(ActiveRecord::Base) and

Open database handles must not be carried across fork.

More information about the mongrel-unicorn mailing list