lib/hobo/scopes/automatic_scopes.rb in hobo-0.8.5 vs lib/hobo/scopes/automatic_scopes.rb in hobo-0.8.6
- old
+ new
@@ -5,13 +5,16 @@
module AutomaticScopes
def create_automatic_scope(name)
ScopeBuilder.new(self, name).create_scope
rescue ActiveRecord::StatementInvalid => e
- # Problem with the database? Don't try to create automatic scopes
- ActiveRecord::Base.logger.warn "!! Database exception during hobo auto-scope creation -- continuing automatic scopes"
- ActiveRecord::Base.logger.warn "!! #{e.to_s}"
+ # 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
end
@@ -194,10 +197,10 @@
def_scope do |time1, time2|
{ :conditions => ["#{column_sql(col)} >= ? AND #{column_sql(col)} <= ?", time1, time2] }
end
# active (a lifecycle state)
- elsif @klass.has_lifecycle? && name.in?(@klass::Lifecycle.state_names)
+ elsif @klass.has_lifecycle? && name.to_sym.in?(@klass::Lifecycle.state_names)
if @klass::Lifecycle.state_names.length == 1
# nothing to check for - create a dummy scope
def_scope :conditions => ""
true