Rails 3.1: Enumerated_attribute breaks scaffolding (easy fix)

We use and recommend the gem enumerated_attribute when you save ‘types’ (such as workflow states) to your rails application.

However, at least for rails 3.1.3, ruby 1.9.2, and the latest released gem 0.2.16, it breaks rails scaffolding completely, throwing the error:

/Users/devmac/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `require': no such file to load — rails_generator (LoadError)

The workaround is to

  1. comment out the gem in your Gemfile,
  2. save the file (NO need to run bundle install),
  3. run your scaffold command,
  4. then un-comment the gem and
  5. re-save the Gemfile.

Adding -c=scaffold_controller also needed if using active_admin

As noted in another post, active_admin seems to break scaffolding unless you add -c=scaffold_controller to the end of the scaffold command.