I have a route set up that I think should work but instead gives me the following routing error: No route matches {:action=>"show", :controller=>"orders", :id=>#<Order id: nil, user_id: nil, paid: nil, created_at: nil, updated_at: nil, trip_id: nil>}. I am using Rails version 3.2.13.
In routes.rb I have get 'orders/new/:trip_id' => 'orders#new', :as => :new_order. This comes before resources :orders in routes.rb.
In the view, I have <%= link_to 'Click here to register for this trip.', new_order_path(@trip.id) %>. This produces the following (what-seems-to-be-correct) HTML in a case where @trip.id = 1: <a href="/orders/new/1">Click here to register for this trip.</a>.
When I run rake:routes, this line (seemingly correctly) is among those that are generated: new_order GET /orders/new/:trip_id(.:format) orders#new.
In orders_controller.rb, the following line appears as the first line in my new method: @trip = Trip.find(params[:trip_id]).
What I can't figure out is why when I click on the link, I get the routing error shown above in the first paragraph. Please help!
Aucun commentaire:
Enregistrer un commentaire