collectiveidea/acts_as_audited — pull request #83 by tyraeltong (2012-01-25 03:04:40+00:00)
Title: Fix problem when using acts_as_audited in conjunction with devise

Because `devise` gem will add a `devise_for :users` into `routes.rb`, and this call will eventually load the User model definition, so if there's a **:only** option defined in User model's *acts_as_audited* call like:

```ruby
class User < ActiveRecord::Base
acts_as_audited :only => [:name, :email]
end
```
and if you migrate the database from scratch, you'll run into the problem, because in `Auditor.rb`:

```ruby
if options[:only]
except = self.column_names - options[:only].flatten.map(&:to_s)
else
except = [self.primary_key, inheritance_column, 'lock_version',
'created_at', 'updated_at', 'created_on', 'updated_on']
except |= Array(options[:except]).collect(&:to_s) if options[:except]
end
```

will call **ActiveRecord::Base.column_names** method which need the db schema in place, which when you do the migration from scratch, is not available yet. So I just simply added a check to see whether the table is defined or not at the beginning of *acts_as_audited* method.