Avner Cohen <[email protected]> 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 -
> https://github.com/rails/rails/issues/1906 - 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
after_fork?
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
ActiveRecord::Base.connection.disconnect!
end
after_fork do |server, worker|
# the following is *required* for Rails + "preload_app true",
defined?(ActiveRecord::Base) and
ActiveRecord::Base.establish_connection
end
Open database handles must not be carried across fork.
_______________________________________________
Unicorn mailing list - [email protected]
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying