shit werkt met vuile hacks
This commit is contained in:
parent
cd78e5719d
commit
73e24e2b55
4 changed files with 28 additions and 5 deletions
|
@ -26,7 +26,7 @@ class OrdersController < ApplicationController
|
||||||
end_order
|
end_order
|
||||||
redirect_to overview_path
|
redirect_to overview_path
|
||||||
else
|
else
|
||||||
redirect_to overview_path
|
redirect_to root_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -38,6 +38,8 @@ class OrdersController < ApplicationController
|
||||||
private
|
private
|
||||||
|
|
||||||
def order_params
|
def order_params
|
||||||
|
#if params.require(:order).permit(:products)?
|
||||||
params.require(:order).permit(:products)
|
params.require(:order).permit(:products)
|
||||||
|
#{}"products"=>"return_products_string"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
class Order < ActiveRecord::Base
|
class Order < ActiveRecord::Base
|
||||||
belongs_to :users
|
belongs_to :users
|
||||||
default_scope -> { order('created_at DESC') }
|
default_scope -> { order('created_at DESC') }
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,17 @@
|
||||||
<li id="order-<%= order.id %>">
|
<li id="order-<%= order.id %>">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<span class="products"><%= order.products %></span>
|
<span class="products"><%= order.products %></span>
|
||||||
<span class="timestamp">
|
<span class="timestamp">
|
||||||
Posted <%= time_ago_in_words(order.created_at) %> ago.
|
Posted <%= time_ago_in_words(order.created_at) %> ago.
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
<script charset="utf-8">
|
||||||
|
var products = JSON.stringify(<%=order.products%> );
|
||||||
|
jQuery.each(products, function(i, product) {
|
||||||
|
$(".products").append("<p> - "+ i +": "+ product.number_of +"</p>");
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
<%= current_ordering_user.name %>
|
<%= current_ordering_user.name %>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<% @products.each do |p| %>
|
<% @products.each do |p| %>
|
||||||
<%#= render "orders/order_button" %>
|
<%#= render "orders/order_button" %>
|
||||||
|
|
||||||
|
@ -17,9 +22,12 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<%= form_for @order do |f| %>
|
<%= form_for @order do |f| %>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<%= 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..." %>
|
||||||
</div>
|
</div>
|
||||||
<%#= hidden_field_tag "products", "return_products_string" %>
|
<%#= hidden_field_tag "products", "return_products_string" %>
|
||||||
<div class="hidden"></div>
|
<div class="hidden"></div>
|
||||||
|
@ -66,13 +74,15 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//updates the orderlist view
|
//updates the orderlist view
|
||||||
var update = function(){
|
var update = function(){
|
||||||
$('.order_list').empty().append("<p>Ordered: </p>" );
|
$('.order_list').empty().append("<p>Ordered: </p>" + JSON.stringify(products) );
|
||||||
jQuery.each(products, function(i, product) {
|
jQuery.each(products, function(i, product) {
|
||||||
$(".order_list").append("<p> - "+ i +": "+ product.number_of +"</p>");
|
$(".order_list").append("<p> - "+ i +": "+ product.number_of +"</p>");
|
||||||
});
|
});
|
||||||
//$('.hidden').empty().append("<input id='products' name='products' type='hidden' value='test' />")
|
$('.hidden').empty().append("<input id='order_products' name='order[products]' type='hidden' value="+ JSON.stringify(products) +" />")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,5 +95,4 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in a new issue