rake db:migrate fails when using devise_for on models that use class methods that hit the db
My User model uses the column_names method to allow mass_assignment on all columns for admins. 

    class User < ActiveRecord::Base

      attr_accessible :email, :password, :password_confirmation, :remember_me
      attr_accessible *column_names, as: :admin 

    end

However, this doesn't play well with my route file that has devise configured

    Sandbox::Application.routes.draw do
      devise_for :users
    end

That is, when I run rake db:migrate RAILS_ENV=test. I get 

    rake aborted!
    Mysql2::Error: Table 'sandbox_test.users' doesn't exist: SHOW FULL FIELDS FROM `users`

Full trace at http://pastie.org/3748502

I know the table doesnt exist, that's why I need to run my migration, but somehow, rake db:migrate RAILS_ENV=test reloads the routes, thus calling devise_for, and devise_for loads User class when adding the devise mapping, thus calling the column_names method on a table that doesn't exist yet. 

So I'm not really sure how to cleanly handle this? Should I add add if table_exists? everytime I want to use column_names method? or is there a better way to handle this problem?

rake db:migrate fails when using devise_for on models that use class methods that hit the db
===

My User model uses the column_names method to allow mass_assignment on all columns for admins. 

    class User < ActiveRecord::Base

      attr_accessible :email, :password, :password_confirmation, :remember_me
      attr_accessible *column_names, as: :admin 

    end

However, this doesn't play well with my route file that has devise configured

    Sandbox::Application.routes.draw do
      devise_for :users
    end

That is, when I run rake db:migrate RAILS_ENV=test. I get 

    rake aborted!
    Mysql2::Error: Table 'sandbox_test.users' doesn't exist: SHOW FULL FIELDS FROM `users`

Full trace at http://pastie.org/3748502

I know the table doesnt exist, that's why I need to run my migration, but somehow, rake db:migrate RAILS_ENV=test reloads the routes, thus calling devise_for, and devise_for loads User class when adding the devise mapping, thus calling the column_names method on a table that doesn't exist yet. 

So I'm not really sure how to cleanly handle this? Should I add add if table_exists? everytime I want to use column_names method? or is there a better way to handle this problem?
