Last active
December 10, 2015 05:29
-
-
Save RemiBa/4388396 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Routing Error | |
No route matches {:controller=>"orderitems"} | |
Try running rake routes for more information on available routes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= 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? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Order < ActiveRecord::Base | |
## ASSOCIATIONS | |
has_many :orderitems | |
has_many :products, :through => :orderitems | |
belongs_to :customer | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Orderitem < ActiveRecord::Base | |
## ASSOCIATIONS | |
belongs_to :product # product (id) | |
belongs_to :order #order (id) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class OrderitemsController < ApplicationController | |
def index | |
end | |
def create | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Product < ActiveRecord::Base | |
#ASSOCIATIONS | |
has_many :orderitems | |
has_many :orders, :through => :orderitems | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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