clean up
This commit is contained in:
parent
1c0a313fdb
commit
b2b9a7a188
8 changed files with 43 additions and 19 deletions
|
@ -5,14 +5,14 @@ class OrdersController < ApplicationController
|
|||
|
||||
|
||||
def new
|
||||
@user = User.find(params[:id])
|
||||
@user = User.find(params[:user_id])
|
||||
@order = @user.orders.build
|
||||
@products = Product.all
|
||||
end
|
||||
|
||||
|
||||
def create
|
||||
@user = User.find(params[:id])
|
||||
@user = User.find(params[:user_id])
|
||||
@order = @user.orders.build(order_params)
|
||||
if @order.save
|
||||
#flash[:success] = "order created!"
|
||||
|
|
|
@ -33,7 +33,9 @@ class ProductsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def delete
|
||||
def destroy
|
||||
Product.find(params[:id]).destroy
|
||||
redirect_to products_path
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -17,10 +17,29 @@ class UsersController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@user = User.find(params[:id])
|
||||
end
|
||||
|
||||
def update
|
||||
@user = User.find(params[:id])
|
||||
if @user.update_attributes(user_params)
|
||||
redirect_to @user
|
||||
else
|
||||
render 'edit'
|
||||
end
|
||||
end
|
||||
|
||||
def index
|
||||
@users = User.all
|
||||
end
|
||||
|
||||
|
||||
def destroy
|
||||
User.find(params[:id]).destroy
|
||||
redirect_to users_path
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def user_params
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
<!-- Collect the nav links, forms, and other content for toggling -->
|
||||
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
|
||||
<ul class="nav navbar-nav">
|
||||
<li><%= link_to "Index" , users_path %> </li>
|
||||
<li><%= link_to "Overview" , overview_path %> </li> <!-- tijdelijk voor iedereen -->
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Products <span class="caret"></span></a>
|
||||
|
@ -20,15 +19,20 @@
|
|||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Users <span class="caret"></span></a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li><a href="#">new</a></li>
|
||||
<li><a href="#">index</a></li>
|
||||
<li><a href="#">edit</a></li>
|
||||
<li><%= link_to "New User", new_user_path %></li>
|
||||
<li><%= link_to "index" , users_path %></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul class="nav navbar-nav navbar-center">
|
||||
<li class="navbar-text">
|
||||
ADMIN NAVBAR
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li><%= link_to "Index" , users_path %> </li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Account <span class="caret"></span></a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
|
|
|
@ -1,15 +1,7 @@
|
|||
<%= @user.name %>
|
||||
|
||||
<% @products.each do |p| %>
|
||||
<%#= render "orders/order_button" %>
|
||||
|
||||
<!-- dit moet in een andere file -->
|
||||
<button class="btn btn-default product-btn"
|
||||
data-name= '<%= p.name %>'
|
||||
date-price= '<%= p.sale_price %>'>
|
||||
<%= p.name %>
|
||||
</button>
|
||||
<!-- tot hier -->
|
||||
<%= render "orders/order_button" , p: p %>
|
||||
<% end %>
|
||||
|
||||
<%= form_for( @order, url: user_orders_path(@user)) do |f| %>
|
||||
|
|
|
@ -3,7 +3,9 @@
|
|||
<ul class="products">
|
||||
<% @products.each do |product| %>
|
||||
<li>
|
||||
<%= link_to product.name, product %>
|
||||
<%= link_to product.name, product %> |
|
||||
<%= link_to "delete", product, method: :delete,
|
||||
data: { confirm: "You sure?" } %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
|
|
@ -3,7 +3,9 @@
|
|||
<ul class="users">
|
||||
<% @users.each do |user| %>
|
||||
<li>
|
||||
<%= link_to user.name, user %>
|
||||
<%= link_to user.name, user %> |
|
||||
<%= link_to "delete", user, method: :delete,
|
||||
data: { confirm: "You sure?" } %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
|
|
@ -6,6 +6,9 @@
|
|||
<h1>Nickname: <%= @user.nickname %></h1>
|
||||
<h1>Balance: <%= @user.balance %></h1>
|
||||
<h1>User id: <%= @user.id %></h1>
|
||||
<p>
|
||||
<%= link_to "edit" , edit_user_path %>
|
||||
</p>
|
||||
|
||||
</section>
|
||||
</aside>
|
||||
|
|
Loading…
Reference in a new issue