rake 路由 rake 中止! ArgumentError:必须使用路径和/或选项调用

Posted

技术标签:

【中文标题】rake 路由 rake 中止! ArgumentError:必须使用路径和/或选项调用【英文标题】:rake routes rake aborted! ArgumentError: must be called with a path and/or options 【发布时间】:2015-02-13 03:36:57 【问题描述】:

我将 root :'lesson#index' 更改为 根('课程#index')

对于错误 /home/govisun/.rvm/gems/ruby-2.1.0/gems/actionpack-4.1.8/lib/action_dispatch/routing/mapper.rb:1504:in root': must be called with a path and/or options (ArgumentError) from /home/govisun/Documents/LessonApp/config/routes.rb:5:inblock in ' 来自/home/govisun/.rvm/gems/ruby-2.1.0/gems/actionpack-4.1.8/lib/action_dispatch/routing/route_set.rb:337:in instance_exec' from /home/govisun/.rvm/gems/ruby-2.1.0/gems/actionpack-4.1.8/lib/action_dispatch/routing/route_set.rb:337:ineval_block' 来自/home/govisun/.rvm/gems/ruby-2.1.0/gems/actionpack-4.1.8/lib/action_dispatch/routing/route_set.rb:315:in draw' from /home/govisun/Documents/LessonApp/config/routes.rb:1:in' 来自/home/govisun/.rvm/gems/ruby-2.1.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:241:in load' from /home/govisun/.rvm/gems/ruby-2.1.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:241:inblock in load' 来自/home/govisun/.rvm/gems/ruby-2.1.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:232:in load_dependency' from /home/govisun/.rvm/gems/ruby-2.1.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:241:inload' 来自/home/govisun/.rvm/gems/ruby-2.1.0/gems/railties-4.1.8/lib/rails/application/routes_reloader.rb:40:in block in load_paths' from /home/govisun/.rvm/gems/ruby-2.1.0/gems/railties-4.1.8/lib/rails/application/routes_reloader.rb:40:ineach' 来自/home/govisun/.rvm/gems/ruby-2.1.0/gems/railties-4.1.8/lib/rails/application/routes_reloader.rb:40:in load_paths' from /home/govisun/.rvm/gems/ruby-2.1.0/gems/railties-4.1.8/lib/rails/application/routes_reloader.rb:16:inreload! 来自/home/govisun/.rvm/gems/ruby-2.1.0/gems/railties-4.1.8/lib/rails/application/routes_reloader.rb:26:in block in updater' from /home/govisun/.rvm/gems/ruby-2.1.0/gems/activesupport-4.1.8/lib/active_support/file_update_checker.rb:75:incall' 来自 /home/govisun/.rvm/gems/ruby-2.1.0/gems/activesupport-4.1.8/lib/active_support/file_update_checker.rb:75:in execute' from /home/govisun/.rvm/gems/ruby-2.1.0/gems/railties-4.1.8/lib/rails/application/routes_reloader.rb:27:inupdater' 来自 /home/govisun/.rvm/gems/ruby-2.1.0/gems/railties-4.1.8/lib/rails/application/routes_reloader.rb:7:in execute_if_updated' from /home/govisun/.rvm/gems/ruby-2.1.0/gems/railties-4.1.8/lib/rails/application/finisher.rb:71:inblock in ' 来自 /home/govisun/.rvm/gems/ruby-2.1.0/gems/railties-4.1.8/lib/rails/initializable.rb:30:in instance_exec' from /home/govisun/.rvm/gems/ruby-2.1.0/gems/railties-4.1.8/lib/rails/initializable.rb:30:inrun' 来自 /home/govisun/.rvm/gems/ruby-2.1.0/gems/railties-4.1.8/lib/rails/initializable.rb:55:in block in run_initializers' from /home/govisun/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/tsort.rb:226:inblock in tsort_each' 来自/home/govisun/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/tsort.rb:348:in block (2 levels) in each_strongly_connected_component' from /home/govisun/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/tsort.rb:427:ineach_strongly_connected_component_from' 来自 /home/govisun/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/tsort.rb:347:in block in each_strongly_connected_component' from /home/govisun/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/tsort.rb:345:ineach' 来自 /home/govisun/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/tsort.rb:345:in call' from /home/govisun/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/tsort.rb:345:ineach_strongly_connected_component' 来自/home/govisun/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/tsort.rb:224:in tsort_each' from /home/govisun/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/tsort.rb:205:intsort_each' 来自/home/govisun/.rvm/gems/ruby-2.1.0/gems/railties-4.1.8/lib/rails/initializable.rb:54:in run_initializers' from /home/govisun/.rvm/gems/ruby-2.1.0/gems/railties-4.1.8/lib/rails/application.rb:300:ininitialize! 来自/home/govisun/Documents/LessonApp/config/environment.rb:5:in <top (required)>' from /home/govisun/.rvm/gems/ruby-2.1.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:247:inrequire' 来自/home/govisun/.rvm/gems/ruby-2.1.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:247:in block in require' from /home/govisun/.rvm/gems/ruby-2.1.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:232:inload_dependency' 来自 /home/govisun/.rvm/gems/ruby-2.1.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:247:in require' from /home/govisun/Documents/LessonApp/config.ru:3:inblock in ' 来自 /home/govisun/.rvm/gems/ruby-2.1.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in instance_eval' from /home/govisun/.rvm/gems/ruby-2.1.0/gems/rack-1.5.2/lib/rack/builder.rb:55:ininitialize' 来自/home/govisun/Documents/LessonApp/config.ru:in new' from /home/govisun/Documents/LessonApp/config.ru:in' 来自/home/govisun/.rvm/gems/ruby-2.1.0/gems/rack-1.5.2/lib/rack/builder.rb:49:in eval' from /home/govisun/.rvm/gems/ruby-2.1.0/gems/rack-1.5.2/lib/rack/builder.rb:49:innew_from_string' 来自/home/govisun/.rvm/gems/ruby-2.1.0/gems/rack-1.5.2/lib/rack/builder.rb:40:in parse_file' from /home/govisun/.rvm/gems/ruby-2.1.0/gems/rack-1.5.2/lib/rack/server.rb:277:inbuild_app_and_options_from_config' 来自 /home/govisun/.rvm/gems/ruby-2.1.0/gems/rack-1.5.2/lib/rack/server.rb:199:in app' from /home/govisun/.rvm/gems/ruby-2.1.0/gems/railties-4.1.8/lib/rails/commands/server.rb:50:inapp' 来自 /home/govisun/.rvm/gems/ruby-2.1.0/gems/rack-1.5.2/lib/rack/server.rb:314:in wrapped_app' from /home/govisun/.rvm/gems/ruby-2.1.0/gems/railties-4.1.8/lib/rails/commands/server.rb:130:inlog_to_stdout' 来自 /home/govisun/.rvm/gems/ruby-2.1.0/gems/railties-4.1.8/lib/rails/commands/server.rb:67:in start' from /home/govisun/.rvm/gems/ruby-2.1.0/gems/railties-4.1.8/lib/rails/commands/commands_tasks.rb:81:inblock in server' 来自/home/govisun/.rvm/gems/ruby-2.1.0/gems/railties-4.1.8/lib/rails/commands/commands_tasks.rb:76:in tap' from /home/govisun/.rvm/gems/ruby-2.1.0/gems/railties-4.1.8/lib/rails/commands/commands_tasks.rb:76:inserver' 来自/home/govisun/.rvm/gems/ruby-2.1.0/gems/railties-4.1.8/lib/rails/commands/commands_tasks.rb:40:in run_command!' from /home/govisun/.rvm/gems/ruby-2.1.0/gems/railties-4.1.8/lib/rails/commands.rb:17:in' 来自 /home/govisun/Documents/LessonApp/bin/rails:8:in require' from /home/govisun/Documents/LessonApp/bin/rails:8:in' 来自/home/govisun/.rvm/gems/ruby-2.1.0/gems/spring-1.2.0/lib/spring/client/rails.rb:27:in load' from /home/govisun/.rvm/gems/ruby-2.1.0/gems/spring-1.2.0/lib/spring/client/rails.rb:27:incall' 来自/home/govisun/.rvm/gems/ruby-2.1.0/gems/spring-1.2.0/lib/spring/client/command.rb:7:in call' from /home/govisun/.rvm/gems/ruby-2.1.0/gems/spring-1.2.0/lib/spring/client.rb:26:inrun' 来自 /home/govisun/.rvm/gems/ruby-2.1.0/gems/spring-1.2.0/bin/spring:48:in <top (required)>' from /home/govisun/.rvm/gems/ruby-2.1.0/gems/spring-1.2.0/lib/spring/binstub.rb:11:inload' 来自/home/govisun/.rvm/gems/ruby-2.1.0/gems/spring-1.2.0/lib/spring/binstub.rb:11:in <top (required)>' from /home/govisun/Documents/LessonApp/bin/spring:16:inrequire' 来自 /home/govisun/Documents/LessonApp/bin/spring:16:in <top (required)>' from bin/rails:3:inload' 从 bin/rails:3:in `'

它成功了:-)

【问题讨论】:

【参考方案1】:

应该是root 'lesson#index'root to: path,如果你要用(),那么请确保root('lesson#index')没有空格。查看api 了解更多信息。

【讨论】:

以上是关于rake 路由 rake 中止! ArgumentError:必须使用路径和/或选项调用的主要内容,如果未能解决你的问题,请参考以下文章

Rails 4 - AwesomeEotPath 之后 Rake 中止,无效的 CSS

rake 中止的数据库将不会迁移

Rails 3.1.1 资产预编译 - rake 中止

Rake 正在中止,因为 sqlite db 的未定义方法“inet”

heroku 运行 rake 资产:预编译中止,因为文件具有无效的 UTF-8 字节序列

Ubuntu rake 中止! NameError:未初始化的常量 ActionDispatch::XmlParamsParser