Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/52.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Rails 3中的深度嵌套路由_Ruby On Rails_Ruby_Ruby On Rails 3 - Fatal编程技术网

Ruby on rails Rails 3中的深度嵌套路由

Ruby on rails Rails 3中的深度嵌套路由,ruby-on-rails,ruby,ruby-on-rails-3,Ruby On Rails,Ruby,Ruby On Rails 3,我在我的show.html.erb中找到了这个: <%= link_to "Pay on this contract", new_product_contract_payment_path %> 但是,当我查看合同页面时,会出现以下错误: 没有路由匹配{:action=>“new”,:controller=>“payments”} 当我使用rake routes并且支付控制器在那里时,就会显示该路由。这是我在payments controller中的新方法 def new

我在我的
show.html.erb
中找到了这个:

<%= link_to "Pay on this contract", new_product_contract_payment_path %>
但是,当我查看合同页面时,会出现以下错误:

没有路由匹配{:action=>“new”,:controller=>“payments”}

当我使用
rake routes
并且支付控制器在那里时,就会显示该路由。这是我在payments controller中的新方法

 def new
    @contract = Contract.find(params[:contract])
    @payment = @contract.line_items.build

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @payment }
    end
  end

你认为是什么导致了这个错误吗?

你需要通过一个合同和一个产品,比如:

 new_product_contract_payment_path(@product, @contract) 

您需要通过合同和产品,因此类似于:

 new_product_contract_payment_path(@product, @contract) 

我应该提到我曾经尝试过并得到了这个错误:
没有路由匹配{:action=>“new”,:controller=>“payments”,:product\u id=>nil,:contract\u id=>}
我应该提到我确实尝试过并得到了这个错误:
没有路由匹配{:action=>“new”,:controller=>“payments”,:product\u id=>nil,:contract\u id=>