diff --git a/app/controllers/orders_controller.rb b/app/controllers/orders_controller.rb index dbf0edb..0c974ce 100644 --- a/app/controllers/orders_controller.rb +++ b/app/controllers/orders_controller.rb @@ -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!" diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb index cd1d2bc..d376414 100644 --- a/app/controllers/products_controller.rb +++ b/app/controllers/products_controller.rb @@ -33,7 +33,9 @@ class ProductsController < ApplicationController end end - def delete + def destroy + Product.find(params[:id]).destroy + redirect_to products_path end private diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 354e835..8b43342 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -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 diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index 869a955..9549175 100644 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -8,7 +8,6 @@