Sha256: 62f0a199f4e5a563b037b2f019117ddff1532a4aff357057ecd8c77b4d960701

Contents?: true

Size: 904 Bytes

Versions: 2

Compression:

Stored size: 904 Bytes

Contents

module Admin

  class Market::ProductsController < BaseController

    handle_return_path

    PER_PAGE = 20

    def index
      @products = ::Market::Product.all.paginate(page: params[:page], per_page: PER_PAGE)
    end

    def new
      @product = ::Market::Product.new
    end

    def create
      @product = ::Market::Product.new(params[:market_product].permit!)
      if @product.save
        redirect_to_back
      else
        render :new
      end
    end

    def edit
      @product = ::Market::Product.find(params[:id])
    end

    def update
      @product = ::Market::Product.find(params[:id])
      if @product.update_attributes(params[:market_product].permit!)
        redirect_to_back
      else
        render :edit
      end
    end

    def destroy
      @product = ::Market::Product.find(params[:id])
      @product.destroy
      redirect_to_back
    end

    private


  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
coalla-cms-0.4.2.0 lib/generators/coalla/cms/market/templates/controllers/products_controller.rb
coalla-cms-0.4.4.3 lib/generators/coalla/cms/market/templates/controllers/products_controller.rb