Sha256: 107b8ae1ce5c553b88d572fa1b96c1d3c2ba1aa8894d267c07f17e6d067b8e87

Contents?: true

Size: 1.85 KB

Versions: 9

Compression:

Stored size: 1.85 KB

Contents

class ProductsController < ActiveGrid::Controller
  # GET /products
  # GET /products.json
  def index
    @products = Product.scoped


    activegrid :products, @products
  end

  # GET /products/1
  # GET /products/1.json
  def show
    @product = Product.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.json { render json: @product }
    end
  end

  # GET /products/new
  # GET /products/new.json
  def new
    @product = Product.new

    respond_to do |format|
      format.html # new.html.erb
      format.json { render json: @product }
    end
  end

  # GET /products/1/edit
  def edit
    @product = Product.find(params[:id])
  end

  # POST /products
  # POST /products.json
  def create
    @product = Product.new(params[:product])

    respond_to do |format|
      if @product.save
        format.html { redirect_to @product, notice: 'Product was successfully created.' }
        format.json { render json: @product, status: :created, location: @product }
      else
        format.html { render action: "new" }
        format.json { render json: @product.errors, status: :unprocessable_entity }
      end
    end
  end

  # PUT /products/1
  # PUT /products/1.json
  def update
    @product = Product.find(params[:id])

    respond_to do |format|
      if @product.update_attributes(params[:product])
        format.html { redirect_to @product, notice: 'Product was successfully updated.' }
        format.json { head :ok }
      else
        format.html { render action: "edit" }
        format.json { render json: @product.errors, status: :unprocessable_entity }
      end
    end
  end

  # DELETE /products/1
  # DELETE /products/1.json
  def destroy
    @product = Product.find(params[:id])
    @product.destroy

    respond_to do |format|
      format.html { redirect_to products_url }
      format.json { head :ok }
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
activegrid-1.0.8 test/dummy/app/controllers/products_controller.rb
activegrid-1.0.7 test/dummy/app/controllers/products_controller.rb
activegrid-1.0.6 test/dummy/app/controllers/products_controller.rb
activegrid-1.0.5 test/dummy/app/controllers/products_controller.rb
activegrid-1.0.4 test/dummy/app/controllers/products_controller.rb
activegrid-1.0.3 test/dummy/app/controllers/products_controller.rb
activegrid-1.0.2 test/dummy/app/controllers/products_controller.rb
activegrid-1.0.1 test/dummy/app/controllers/products_controller.rb
activegrid-1.0.0 test/dummy/app/controllers/products_controller.rb