Instantly share code, notes, and snippets.

Embed
What would you like to do?
Devise + Spork + Rails 3.1 RC4 hacks to keep User model from loading prefork
Spork.prefork do
require "rails/application"
# Prevent Devise from loading the User model super early with it's route hacks for Rails 3.1 rc4
# see also: https://github.com/timcharper/spork/wiki/Spork.trap_method-Jujutsu
Spork.trap_method(Rails::Application, :reload_routes!)
Spork.trap_method(Rails::Application::RoutesReloader, :reload!)
# rest of your prefork here...
end
@rsanheim

This comment has been minimized.

Show comment
Hide comment
@rsanheim

rsanheim Jun 29, 2011

The new line is the RoutesReloader one (line 6) -- apparently Rails 3.1 added that.

Owner

rsanheim commented Jun 29, 2011

The new line is the RoutesReloader one (line 6) -- apparently Rails 3.1 added that.

@jfirebaugh

This comment has been minimized.

Show comment
Hide comment
@jfirebaugh

jfirebaugh commented Feb 28, 2012

@jibiel

This comment has been minimized.

Show comment
Hide comment
@jibiel

jibiel Nov 1, 2012

Too bad it didn't work for me on rails 3.2.8 with devise 2.1.2.

jibiel commented Nov 1, 2012

Too bad it didn't work for me on rails 3.2.8 with devise 2.1.2.

@robbytobby

This comment has been minimized.

Show comment
Hide comment
@robbytobby

robbytobby May 29, 2013

The above fix works for me on rails 3.2.13 with spork 1.0.0rc3 and devise 2.2.4. But it's essential that these lines are the first ones in the prefork block

require "rails/application"
Spork.trap_method(Rails::Application::RoutesReloader, :reload!)
require File.expand_path("../../config/environment", __FILE__)

robbytobby commented May 29, 2013

The above fix works for me on rails 3.2.13 with spork 1.0.0rc3 and devise 2.2.4. But it's essential that these lines are the first ones in the prefork block

require "rails/application"
Spork.trap_method(Rails::Application::RoutesReloader, :reload!)
require File.expand_path("../../config/environment", __FILE__)
@DavidVII

This comment has been minimized.

Show comment
Hide comment
@DavidVII

DavidVII Oct 14, 2013

Thanks, @robbytobby! That worked nicely for me.

DavidVII commented Oct 14, 2013

Thanks, @robbytobby! That worked nicely for me.

@skrobul

This comment has been minimized.

Show comment
Hide comment
@skrobul

skrobul Jan 20, 2014

works with Rails 4 as well

skrobul commented Jan 20, 2014

works with Rails 4 as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment