Created
          June 29, 2011 15:23 
        
      - 
      
 - 
        
Save rsanheim/1054078 to your computer and use it in GitHub Desktop.  
    Devise + Spork + Rails 3.1 RC4 hacks to keep User model from loading prefork
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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 | 
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__)
    Thanks, @robbytobby! That worked nicely for me.
works with Rails 4 as well
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
Too bad it didn't work for me on
rails 3.2.8withdevise 2.1.2.