我正在尝试polymorphic_path
在 Rails 3 的功能测试中使用。
起初我会得到
NoMethodError: undefined method `polymorphic_path' for #<ArticlesControllerTest:0x492f17c>
然后我添加了
include Rails.application.routes.url_helpers
已undefined method error
停止但现在是常规路径,article_path(article)
例如停止工作:
NameError: undefined local variable or method `default_url_options' for #<ArticlesControllerTest:0x33ccbe0>
.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.0.9/lib/action_dispatch/testing/assertions/routing.rb:175:in `method_missing'
.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.0.9/lib/action_dispatch/routing/url_for.rb:102:in `url_options'
.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.0.9/lib/action_dispatch/routing/url_for.rb:131:in `url_for'
.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.0.9/lib/action_dispatch/routing/route_set.rb:195:in `article_path'
我曾经能够通过包含在 Rails 2 中正常使用 polymorphic_path
include ActionController::UrlWriter
我怎样才能让它在 Rails 3 中工作?