pluginaweek/state_machine — Issue #149: Fail on Rails 3.1.3
Author: benbjohnson
Created: 2011-12-29 18:40:24+00:00
State: open

On a new installation of Rails 3.1.3 with state_machine 1.1.0, I receive the following error:

blackdog:test_app benbjohnson$ rails db:create --trace
rake aborted!
wrong number of arguments (1 for 0)
/Users/benbjohnson/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.1.3/lib/rails/engine.rb:566:in `block in '
/Users/benbjohnson/.rvm/gems/ruby-1.9.3-p0/gems/statemachine-1.1.1/lib/statemachine/action_invokation.rb:57:in `instance_exec'
/Users/benbjohnson/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.1.3/lib/rails/railtie.rb:188:in `block in load_tasks'
/Users/benbjohnson/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.1.3/lib/rails/railtie.rb:188:in `each'
/Users/benbjohnson/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.1.3/lib/rails/railtie.rb:188:in `load_tasks'
/Users/benbjohnson/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.1.3/lib/rails/engine.rb:397:in `load_tasks'
/Users/benbjohnson/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.1.3/lib/rails/engine.rb:396:in `block in load_tasks'
/Users/benbjohnson/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.1.3/lib/rails/application/railties.rb:8:in `each'
/Users/benbjohnson/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.1.3/lib/rails/application/railties.rb:8:in `all'
/Users/benbjohnson/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.1.3/lib/rails/engine.rb:396:in `load_tasks'
/Users/benbjohnson/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.1.3/lib/rails/application.rb:103:in `load_tasks'
/Users/benbjohnson/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.1.3/lib/rails/railtie/configurable.rb:30:in `method_missing'
/private/tmp/test_app/Rakefile:7:in `'
/Users/benbjohnson/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load'
/Users/benbjohnson/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load_rakefile'
/Users/benbjohnson/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:501:in `raw_load_rakefile'
/Users/benbjohnson/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:82:in `block in load_rakefile'
/Users/benbjohnson/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/benbjohnson/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:81:in `load_rakefile'
/Users/benbjohnson/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:65:in `block in run'
/Users/benbjohnson/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/benbjohnson/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/Users/benbjohnson/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/bin/rake:33:in `'
/Users/benbjohnson/.rvm/gems/ruby-1.9.3-p0/bin/rake:19:in `load'
/Users/benbjohnson/.rvm/gems/ruby-1.9.3-p0/bin/rake:19:in `

'

It looks like state_machine is trying to call Railties' `Engine#rake_tasks` block and trying to pass an argument when one is not excepted. The single argument being passed in is the `Application` object but the `rake_tasks` block expects to use `self` to reference the `Application`.

I haven't created a Pull Request since I really what to do to fix it while being backwards compatible. Should it switch between passing a single argument or no arguments based on Rails version?