mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-02-01 05:01:04 -05:00
74 lines
1.4 KiB
Ruby
74 lines
1.4 KiB
Ruby
class ProductsController < ApplicationController
|
|
before_action :authenticate_member!
|
|
load_and_authorize_resource
|
|
|
|
# GET /products
|
|
def index
|
|
@products = Product.all
|
|
|
|
respond_to do |format|
|
|
format.html # index.html.erb
|
|
end
|
|
end
|
|
|
|
# GET /products/1
|
|
def show
|
|
respond_to do |format|
|
|
format.html # show.html.erb
|
|
end
|
|
end
|
|
|
|
# GET /products/new
|
|
def new
|
|
@product = Product.new
|
|
|
|
respond_to do |format|
|
|
format.html # new.html.erb
|
|
end
|
|
end
|
|
|
|
# GET /products/1/edit
|
|
def edit
|
|
end
|
|
|
|
# POST /products
|
|
def create
|
|
@product = Product.new(product_params)
|
|
|
|
respond_to do |format|
|
|
if @product.save
|
|
format.html { redirect_to @product, notice: 'Product was successfully created.' }
|
|
else
|
|
format.html { render action: "new" }
|
|
end
|
|
end
|
|
end
|
|
|
|
# PUT /products/1
|
|
def update
|
|
respond_to do |format|
|
|
if @product.update(product_params)
|
|
format.html { redirect_to @product, notice: 'Product was successfully updated.' }
|
|
else
|
|
format.html { render action: "edit" }
|
|
end
|
|
end
|
|
end
|
|
|
|
# DELETE /products/1
|
|
def destroy
|
|
@product.destroy
|
|
|
|
respond_to do |format|
|
|
format.html { redirect_to products_url }
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def product_params
|
|
params.require(:product).permit(:description, :min_price, :recommended_price, :name,
|
|
:account_type_id, :paid_months)
|
|
end
|
|
end
|