This project is archived and is in readonly mode.

#1010 ✓wontfix
Akira Matsuda

named route named 'task' or 'desc' causes problems with rake command

Reported by Akira Matsuda | September 10th, 2008 @ 11:09 AM | in 2.x

With a config/routes.rb file like this,


ActionController::Routing::Routes.draw do |map|
  map.with_options :controller => 'tasks' do |t|
    t.task 'someurl', :action => 'index'
  end
end

% rake --trace routes

(or some other rake tasks like db:migrate) command fails with the following strange error.


** Invoke routes (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
Unrecognized keys in task hash: [:action, :controller]
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1656:in `resolve_args'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1610:in `define_task'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:651:in `define_task'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:758:in `task'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/active_support/option_merger.rb:14:in `send!'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/active_support/option_merger.rb:14:in `method_missing'
/Users/matsuda/work/src/rails/task_routes_bug/config/routes.rb:3
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/active_support/core_ext/object/misc.rb:48:in `with_options'
/Users/matsuda/work/src/rails/task_routes_bug/config/routes.rb:2
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.1.1/lib/action_controller/routing/route_set.rb:207:in `draw'
/Users/matsuda/work/src/rails/task_routes_bug/config/routes.rb:1
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/active_support/dependencies.rb:503:in `load'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/active_support/dependencies.rb:503:in `load'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/active_support/dependencies.rb:355:in `new_constants_in'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/active_support/dependencies.rb:503:in `load'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.1.1/lib/action_controller/routing/route_set.rb:253:in `load_routes!'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.1.1/lib/action_controller/routing/route_set.rb:233:in `load!'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.1.1/lib/action_controller/routing/route_set.rb:248:in `reload'
/opt/local/lib/ruby/gems/1.8/gems/rails-2.1.1/lib/initializer.rb:418:in `initialize_routing'
/opt/local/lib/ruby/gems/1.8/gems/rails-2.1.1/lib/initializer.rb:158:in `process'
/opt/local/lib/ruby/gems/1.8/gems/rails-2.1.1/lib/initializer.rb:97:in `send'
/opt/local/lib/ruby/gems/1.8/gems/rails-2.1.1/lib/initializer.rb:97:in `run'
/Users/matsuda/work/src/rails/task_routes_bug/config/environment.rb:13
/opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
/opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/active_support/dependencies.rb:510:in `require'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/active_support/dependencies.rb:355:in `new_constants_in'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/active_support/dependencies.rb:510:in `require'
/opt/local/lib/ruby/gems/1.8/gems/rails-2.1.1/lib/tasks/misc.rake:3
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `call'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `execute'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `each'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `execute'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:508:in `invoke_with_call_chain'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in `synchronize'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in `invoke_with_call_chain'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:518:in `invoke_prerequisites'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1183:in `each'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1183:in `send'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1183:in `each'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:515:in `invoke_prerequisites'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:507:in `invoke_with_call_chain'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in `synchronize'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in `invoke_with_call_chain'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:494:in `invoke'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1931:in `invoke_task'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `top_level'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `each'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `top_level'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in `standard_exception_handling'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1903:in `top_level'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1881:in `run'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in `standard_exception_handling'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1878:in `run'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.1/bin/rake:31
/opt/local/bin/rake:19:in `load'
/opt/local/bin/rake:19

Same problem occurs with map.namespace like this,


  map.namespace :admin do |admin|
    admin.task 'someurl', :controller => 'tasks', :action => 'index'
  end

and a named route 'desc' also causes

wrong number of arguments (2 for 1) error.

I tried Rails 2.1.1, 2.0.4 and edge, Rake 0.8.1 and Rake 0.8.2, all of which resulted in the same kind of error.

Comments and changes to this ticket

  • Frederick Cheung

    Frederick Cheung December 19th, 2008 @ 06:42 PM

    • State changed from “new” to “wontfix”

    The map object has a little bit of niceness that means that you can write

    
      map.some_route, ...
    

    instead of

    
      map.named_route :some_route, ...
    

    This niceness goes via method missing so it can't work on any preexisting methods (eg you couldn't make a named_route called connect with the short form). task and desc and added as top level methods by rake and so you can't use those either.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Pages