0

我有以下表格声明:

<%= semantic_form_for @contrat_line, 
    :url => url_for(:controller =>"/backend/orders/#{@contrat.id}/contrat_lines", 
        :action =>"create") do |f| %>

我想走以下路线:

POST    /backend/orders/:order_id/contrat_lines(.:format)   backend/contrat_lines#create

但是当我想显示表单时(甚至在使用它之前)出现以下错误:

No route matches {:controller=>"backend/orders/23/contrat_lines", :action=>"create"}

我会说这条路线存在,为什么说它不存在?

4

2 回答 2

1

routes.rb 代码

match "/backend/orders/:order_id/contrat_lines" => "orders#contrat_lines", :as => "contrat_lines"

然后,查看代码

<%= semantic_form_for @contrat_line, 
    :url => contrat_lines_url(:order_id => @contrat.id), 
        :action =>"create") do |f| %>
于 2013-01-14T11:28:42.467 回答
0

Thanks to salil i devised the following form :

backend_order_contrat_lines_url(:order_id => @contrat.id), :action =>"create" do |f| %>

And it works with thoses routes :

namespace :backend do
    resources :orders do
      resources :contrat_lines
    end
end

Thx a lot!, if you want i can edit your answer and set it as accepted.

于 2013-01-14T11:54:24.170 回答