From 73e24e2b55a2d9ae4e826165cc5f29d8b9e7d538 Mon Sep 17 00:00:00 2001 From: ohsab Date: Tue, 25 Nov 2014 02:01:57 +0100 Subject: [PATCH] shit werkt met vuile hacks --- app/controllers/orders_controller.rb | 4 +++- app/models/order.rb | 1 + app/views/orders/_order.html.erb | 11 +++++++++++ app/views/orders/order.html.erb | 17 +++++++++++++---- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/app/controllers/orders_controller.rb b/app/controllers/orders_controller.rb index 630c7d5..88b9f2a 100644 --- a/app/controllers/orders_controller.rb +++ b/app/controllers/orders_controller.rb @@ -26,7 +26,7 @@ class OrdersController < ApplicationController end_order redirect_to overview_path else - redirect_to overview_path + redirect_to root_path end end @@ -38,6 +38,8 @@ class OrdersController < ApplicationController private def order_params + #if params.require(:order).permit(:products)? params.require(:order).permit(:products) + #{}"products"=>"return_products_string" end end diff --git a/app/models/order.rb b/app/models/order.rb index e94fa0d..6b5f99d 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -1,4 +1,5 @@ class Order < ActiveRecord::Base belongs_to :users default_scope -> { order('created_at DESC') } + end diff --git a/app/views/orders/_order.html.erb b/app/views/orders/_order.html.erb index 7219fa9..58782af 100644 --- a/app/views/orders/_order.html.erb +++ b/app/views/orders/_order.html.erb @@ -1,6 +1,17 @@
  • + + + + <%= order.products %> Posted <%= time_ago_in_words(order.created_at) %> ago.
  • + + diff --git a/app/views/orders/order.html.erb b/app/views/orders/order.html.erb index ae5a710..5055d0e 100644 --- a/app/views/orders/order.html.erb +++ b/app/views/orders/order.html.erb @@ -1,5 +1,10 @@ <%= current_ordering_user.name %> + + + + + <% @products.each do |p| %> <%#= render "orders/order_button" %> @@ -17,9 +22,12 @@ + + + <%= form_for @order do |f| %>
    - <%= f.text_area :products , placeholder: "dit zou een hidden field moeten zijn met product JSON..." %> + <%#= f.text_area :products , placeholder: "dit zou een hidden field moeten zijn met product JSON..." %>
    <%#= hidden_field_tag "products", "return_products_string" %> @@ -66,13 +74,15 @@ + + //updates the orderlist view var update = function(){ - $('.order_list').empty().append("

    Ordered:

    " ); + $('.order_list').empty().append("

    Ordered:

    " + JSON.stringify(products) ); jQuery.each(products, function(i, product) { $(".order_list").append("

    - "+ i +": "+ product.number_of +"

    "); }); - //$('.hidden').empty().append("") + $('.hidden').empty().append("") } @@ -85,5 +95,4 @@ -