我的路线是:规范嵌套路线
resources :posts
resources :images
end
,我想写规格为ImagesController:
it "renders the index template" do
get :index, {:id => @post.id}
expect(response).to render_template("index")
end
误差
No route matches {:action=>"index", :controller=>"images", :id=>"19"}
我该如何解决这个问题?
编辑:
固定与post_id
,但似乎仍然没有得到参数:
新的错误是
Failure/Error: get :index, {post_id: @post.id}
NoMethodError: undefined method `+' for nil:NilClass
索引视图:
def index
@post = Post.find(params[:post_id])
@calculations = @post.something + 1
end
'得到:指数:POST_ID => @post .id' –
@AndreyDeineko'故障/错误:得到:指数,{:POST_ID => @ post.id} NoMethodError: 未定义的方法'+”为零:NilClass' 和我有@post definied当然 –
的你认为我可以帮忙吗?你有最新的吗?至少它不再说没有路线,所以它解决了问题 –