小编jos*_*hsz的帖子

Cucumber + Capybara:在我的应用程序之外重定向浏览器的方案存在问题

Given I have a rails app
And I'm using cucumber
And I'm using capybara
And I have an action that results in a redirect_to "http://some.other.domain.com/some_path"
When I test this action
Then the in-app portion of the test works fine
But I see this error: No route matches "/some_path" with {:method=>:get} (ActionController::RoutingError)
Run Code Online (Sandbox Code Playgroud)

所以capybara被正确地重定向到" http://some.other.domain.com/some_path "但由于某种原因它认为它应该处理我的应用程序内的url的路径部分.注意使用" http://some.other.domain.com/ "时,水豚没有任何问题- 如果我重定向到没有路径部分的网址,我的测试就会通过.

这是一个错误吗?

ruby bdd ruby-on-rails cucumber

14
推荐指数
2
解决办法
4237
查看次数

如何在所有模型上添加has_many关联

现在我有一个初始化器,它执行此操作:

ActiveRecord::Base.send :has_many, :notes, :as => :notable ActiveRecord::Base.send :accepts_nested_attributes_for, :notes

它构建关联就好了,除非我加载一个使用它的视图,第二个加载给我: can't dup NilClass from:

/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:2184:in `dup'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:2184:in `scoped_methods'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:2188:in `current_scoped_methods'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:2171:in `scoped?'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:2439:in `send'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:2439:in `initialize'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/reflection.rb:162:in `new'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/reflection.rb:162:in `build_association'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/associations/association_collection.rb:423:in `build_record'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/associations/association_collection.rb:102:in `build'
(my app)/controllers/manifests_controller.rb:21:in `show'
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?我这样做是错误的吗?有趣的是,如果我将关联移动到我正在使用的模型上,我不会得到这个错误.我想我必须错误地构建全局关联.

ruby activerecord ruby-on-rails polymorphic-associations

1
推荐指数
1
解决办法
916
查看次数