4
我有一个嵌套在用户资源中的Story资源。 如何解决这个生成功能测试?功能测试和嵌套资源
test "should create story" do
assert_difference('Story.count') do
post :create, story: @story.attributes
end
assert_redirected_to story_path(assigns(:story))
end
DGM解决方案仍然有story_url问题
这就是我得到的:StoriesControllerTest test_should_create_story错误 未定义的方法'story_url'为# STDERR: 例外'NoMethodError'位于/Users/Simone/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.1.1/lib/ action_dispatch/routing/polymorphic_routes.rb:127:in'polymorphic_url'[012] –
好吧,这是我的错。 #create中的redirect_to仍然只使用@story而不是[@user,@ story] –