less than 1 minute

Rails 3.1 devise_for breaks db:migrate - fix

Maybe you've encountered this incredible annoying devise bug which prevents you from successfully running rake tasks like db:migrate, db:schema:load and so on..

Published Apr 21, 2012 in programming with tags: devise rails

The generated error is always the same:

Devise error: ActiveRecord::StatementInvalid: Mysql2::Error: Table 'skills.users' doesn't exist: SHOW FIELDS FROM `users`

Sadly it’s a chicken and egg problem, the root of the problem is a small, simple line in your routes.rb file:

devise_for :users

I came to understand it has something to do with user model class methods and scopes which access the user model itself. When migrating devise scans the user model and tries something ( I regret to say I have no idea what…) but the table obviously doen’t exist yet. The only working solution (pretty ugly but working though) is simply catching any exception generated by the devise_for statement:

    devise_for :users
  rescue Exception => e
    puts "Devise error: #{e.class}: #{e}"

If anyone knows the real root of the problem and the ultimate, beautiful solution don’t hesitate and provide!

less than 1 minute

Install Node.js on Centos 5.5

How to install node.js on Centos 5.5 Server?

Published Apr 20, 2012 in programming