Skip to content

Commit

Permalink
Use lambda when defining Rails 3 scopes
Browse files Browse the repository at this point in the history
  • Loading branch information
Laurens Nienhaus committed Jun 27, 2014
1 parent 17cf055 commit 56ffc62
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions lib/aasm/persistence/base.rb
Expand Up @@ -91,14 +91,10 @@ def state_with_scope(name, *args)
if @klass.ancestors.map {|klass| klass.to_s}.include?("ActiveRecord::Base")

conditions = {"#{@klass.table_name}.#{@klass.aasm_column}" => name.to_s}
if ActiveRecord::VERSION::MAJOR >= 4
if ActiveRecord::VERSION::MAJOR >= 3
@klass.class_eval do
scope name, lambda { where(conditions) }
end
elsif ActiveRecord::VERSION::MAJOR >= 3
@klass.class_eval do
scope name, where(conditions)
end
else
@klass.class_eval do
named_scope name, :conditions => conditions
Expand Down

0 comments on commit 56ffc62

Please sign in to comment.