Skip to content

Commit

Permalink
Make sure we are connected before table_exists?
Browse files Browse the repository at this point in the history
Because otherwise it will bail because it cannot connect to a DB when doing things like precompiling assets.

Test with:

```
env -i GEM_PATH=$GEM_PATH \
       PATH=$PATH \
       DATABASE_URL=postgres://user:[email protected]/dbname \
       /bin/sh -c 'bundle exec rake --trace  assets:precompile'
```
  • Loading branch information
tecnobrat committed Jan 31, 2014
1 parent fa81274 commit 0b00fa4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/rolify/configure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ def sanity_check(role_cnames)
role_cnames = [ "Role" ] if role_cnames.empty?
role_cnames.each do |role_cname|
role_class = role_cname.constantize
if role_class.superclass.to_s == "ActiveRecord::Base" && !role_class.table_exists?
if role_class.connected? && role_class.superclass.to_s == "ActiveRecord::Base" && !role_class.table_exists?
warn "[WARN] table '#{role_cname}' doesn't exist. Did you run the migration ? Ignoring rolify config."
return false
end
end
true
end
end
end
end

0 comments on commit 0b00fa4

Please sign in to comment.