Add index action and view for orders

This commit is contained in:
Benjamin Cousaert 2014-12-06 12:03:08 +01:00
parent c3729a5964
commit c06c8cacd2
5 changed files with 14 additions and 8 deletions

View file

@ -28,6 +28,11 @@ class OrdersController < ApplicationController
end
end
def index
@user = User.find(params[:user_id])
@orders = @user.orders
end
private
def order_params

View file

@ -0,0 +1,5 @@
<p>
<% order.products.each do |p| %>
<%= p.order_products.find_by(order: order).count.to_s + " " + p.name %>
<% end %>
</p>

View file

@ -0,0 +1,3 @@
<h2><%= @user.nickname %></h2>
<%= render @orders %>

View file

@ -13,10 +13,3 @@
<% end %>
<%= f.submit "Order", class: "btn btn-primary " %>
<% end %>
<div style="padding-top: 50px;" class="order_list ">
<p>
Nothing ordered yet!
</p>
</div>

View file

@ -3,7 +3,7 @@ Rails.application.routes.draw do
root "users#index"
resources :users do
resources :orders, only: [:new, :create]
resources :orders, only: [:new, :create, :index]
end
resources :products