Reputation: 3829
I have the following form declaration :
<%= semantic_form_for @contrat_line,
:url => url_for(:controller =>"/backend/orders/#{@contrat.id}/contrat_lines",
:action =>"create") do |f| %>
I want to hit the following route :
POST /backend/orders/:order_id/contrat_lines(.:format) backend/contrat_lines#create
but i have the following error when i want to display the form (even before using it):
No route matches {:controller=>"backend/orders/23/contrat_lines", :action=>"create"}
I would say this route exist, why is it saying that it does not?
Upvotes: 0
Views: 54
Reputation: 47482
routes.rb code
match "/backend/orders/:order_id/contrat_lines" => "orders#contrat_lines", :as => "contrat_lines"
then, view code
<%= semantic_form_for @contrat_line,
:url => contrat_lines_url(:order_id => @contrat.id),
:action =>"create") do |f| %>
Upvotes: 1
Reputation: 3829
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.
Upvotes: 0