Module: Hobo::Model::Scopes::AutomaticScopes

Included in:
ClassMethods
Defined in:
lib/hobo/model/scopes/automatic_scopes.rb

Instance Method Summary collapse

Instance Method Details

#create_automatic_scope(name, check_only = false) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/hobo/model/scopes/automatic_scopes.rb', line 7

def create_automatic_scope(name, check_only=false)
  ScopeBuilder.new(self, name).create_scope(check_only)
rescue ActiveRecord::StatementInvalid => e
  # Problem with the database? Don't try to create automatic
  # scopes
  if ActiveRecord::Base.logger
    ActiveRecord::Base.logger.warn "!! Database exception during hobo auto-scope creation -- continuing automatic scopes"
    ActiveRecord::Base.logger.warn "!! #{e.to_s}"
  end
  false
end