Skip to content

Instantly share code, notes, and snippets.

@RemiBa
Last active December 10, 2015 05:29
Show Gist options
  • Save RemiBa/4388396 to your computer and use it in GitHub Desktop.
Save RemiBa/4388396 to your computer and use it in GitHub Desktop.
Routing Error
No route matches {:controller=>"orderitems"}
Try running rake routes for more information on available routes.
<%= link_to "Add to order", create_orderitem_path(@order, product) %>
-> @order already exists, product also they have to be merged now into the join table.
-> What is te proper path to use? order_orderitems_path(@currentOrder, product- doesn't work --> POST method not set
--> How to set the post-method with that specific path?
class Order < ActiveRecord::Base
## ASSOCIATIONS
has_many :orderitems
has_many :products, :through => :orderitems
belongs_to :customer
end
class Orderitem < ActiveRecord::Base
## ASSOCIATIONS
belongs_to :product # product (id)
belongs_to :order #order (id)
end
class OrderitemsController < ApplicationController
def index
end
def create
end
end
class Product < ActiveRecord::Base
#ASSOCIATIONS
has_many :orderitems
has_many :orders, :through => :orderitems
end
order_orderitems GET /orders/:order_id/orderitems(.:format)
orderitems#index
POST /orders/:order_id/orderitems(.:format)
orderitems#create
new_order_orderitem GET /orders/:order_id/orderitems/new(.:format)
orderitems#new
edit_order_orderitem GET /orders/:order_id/orderitems/:id/edit(.:form
at) orderitems#edit
order_orderitem GET /orders/:order_id/orderitems/:id(.:format)
orderitems#show
PUT /orders/:order_id/orderitems/:id(.:format)
orderitems#update
DELETE /orders/:order_id/orderitems/:id(.:format)
orderitems#destroy
GET /orders(.:format)
orders#index
POST /orders(.:format)
orders#create
new_order GET /orders/new(.:format)
orders#new
edit_order GET /orders/:id/edit(.:format)
orders#edit
order GET /orders/:id(.:format)
orders#show
PUT /orders/:id(.:format)
orders#update
DELETE /orders/:id(.:format)
orders#destroy
Bom::Application.routes.draw do
resources :customers do
resources :orders
end
resources :orders do
resources :orderitems
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment