0

我正在使用 rspec 和 poltergeist/phantomjs 测试我的应用程序,并且在我安装 gemfriendly_id 以更改我的默认路由后,我的所有 javascript 测试都开始抛出此错误:

Failure/Error: Unable to find matching line from backtrace
    ActiveRecord::RecordNotFound:
        Couldn't find SelectionProcess with id = assets

我在 test.rb 中的资产配置:

config.serve_static_assets = true 
config.static_cache_control = "public, max-age=3600"

回溯的最后几行:

 # /Users/Augusto/.rvm/gems/ruby-1.9.3-p362@startupbase/gems/activerecord-3.2.12/lib/active_record/relation/finder_methods.rb:267:in `find_by_attributes'
 # /Users/Augusto/.rvm/gems/ruby-1.9.3-p362@startupbase/gems/activerecord-3.2.12/lib/active_record/dynamic_matchers.rb:50:in `method_missing'
 # /Users/Augusto/.rvm/gems/ruby-1.9.3-p362@startupbase/gems/cancan-1.6.9/lib/cancan/controller_resource.rb:109:in `find_resource'
 # /Users/Augusto/.rvm/gems/ruby-1.9.3-p362@startupbase/gems/cancan-1.6.9/lib/cancan/controller_resource.rb:68:in `load_resource_instance'
 # /Users/Augusto/.rvm/gems/ruby-1.9.3-p362@startupbase/gems/cancan-1.6.9/lib/cancan/controller_resource.rb:32:in `load_resource'
 # /Users/Augusto/.rvm/gems/ruby-1.9.3-p362@startupbase/gems/cancan-1.6.9/lib/cancan/controller_resource.rb:10:in `block in add_before_filter'
4

1 回答 1

0

听起来friendly_id 也开始用于资产网址。如果您为根 url (/) 定义友好 ID,则所有资产请求 (/assets) 都将被接管。因此,Rails 尝试查找 id = assets 的记录。

于 2013-04-03T20:08:11.210 回答