Files
growstuff/app/controllers/products_controller.rb
2017-11-29 20:59:37 +13:00

47 lines
813 B
Ruby

class ProductsController < ApplicationController
before_action :authenticate_member!
load_and_authorize_resource
respond_to :html
responders :flash
def index
@products = Product.all.order(:name)
respond_with @products
end
def show
respond_with @product
end
def new
@product = Product.new
respond_with @product
end
def edit
respond_with @product
end
def create
@product = Product.create(product_params)
respond_with @product
end
def update
@product.update(product_params)
respond_with @product
end
def destroy
@product.destroy
respond_with @product
end
private
def product_params
params.require(:product).permit(:description, :min_price, :recommended_price, :name,
:account_type_id, :paid_months)
end
end