I am starting to learn how to use rake tasks my first rake task is to show "Hello World"
tasks :greet do
puts "Hello World"
end
But for some reason I have the following error
$ rails -v
Rails 3.2.12
$ ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.5.0]
$ gem -v
2.0.3
This is the command that I am using:
$ rake greet --trace
rake aborted!
undefined method `tasks' for main:Object
/Users/jcr/web/examen-dev/lib/tasks/myfirst.rake:1:in `<top (required)>'
/Users/jcr/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:245:in `load'
/Users/jcr/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:245:in `block in load'
/Users/jcr/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:236:in `load_dependency'
/Users/jcr/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-
3.2.12/lib/active_support/dependencies.rb:245:in `load'
/Users/jcr/.rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.12/lib/rails/engine.rb:425:in `block in load_tasks'
/Users/jcr/.rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.12/lib/rails/engine.rb:425:in `each'
/Users/jcr/.rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.12/lib/rails/engine.rb:425:in `load_tasks'
/Users/jcr/.rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.12/lib/rails/application.rb:145:in `load_tasks'
/Users/jcr/.rvm/gems/ruby-2.0.0-p247/gems/railties-3.2.12/lib/rails/railtie/configurable.rb:30:in `method_missing'
/Users/jcr/web/examen-dev/Rakefile:7:in `<top (required)>'
/Users/jcr/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.0/lib/rake/rake_module.rb:25:in `load'
/Users/jcr/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.0/lib/rake/rake_module.rb:25:in `load_rakefile'
/Users/jcr/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.0/lib/rake/application.rb:637:in `raw_load_rakefile'
/Users/jcr/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.0/lib/rake/application.rb:94:in `block in load_rakefile'
/Users/jcr/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/Users/jcr/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.0/lib/rake/application.rb:93:in `load_rakefile'
/Users/jcr/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.0/lib/rake/application.rb:77:in `block in run'
/Users/jcr/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/Users/jcr/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.0/lib/rake/application.rb:75:in `run'
/Users/jcr/.rvm/gems/ruby-2.0.0-p247/gems/rake-10.1.0/bin/rake:33:in `<top (required)>'
/Users/jcr/.rvm/gems/ruby-2.0.0-p247/bin/rake:23:in `load'
/Users/jcr/.rvm/gems/ruby-2.0.0-p247/bin/rake:23:in `<main>'
Please could you give me some advise in order to fix this error?
Thank you
Replace tasks by task and it should work!