rubyist/aasm — Issue #45: New syntax does not create scopes for the states
Author: evilchelu
Created: 2012-02-21 11:11:15+00:00
State: open

ActiveRecordPersistence creates the named scopes for each action by hooking into aasm_state. This method is no longer used when using the new syntax, therefore the scopes are no longer created

aasm 3.0.2, rails 3.2.1, ruby 1.9.3-p0

As a temporary workaround, I've added an initializer to my app to create them:

````
module AASM
class Base
def state_with_scopes_hax(name, options={})
state_without_scopes_hax name, options

@clazz.singleton_class.send(:define_method, name) do
where(:state => name)
end
end

alias_method :state_without_scopes_hax, :state
alias_method :state, :state_with_scopes_hax
end
end
````