Sha256: 28c9a19450cbc67cdff821006ec0d9b27a43d02889eba662ae9aca80b423a4ef

Contents?: true

Size: 608 Bytes

Versions: 1

Compression:

Stored size: 608 Bytes

Contents

class ProductsController < ApplicationController
  def index
    @products = Product.all
  end

  def new
    @product = Product.new
  end

  def create
    @product = Product.new(product_params)
    if @product.save
      redirect_to products_path
    else
      render :new
    end
  end

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

  def update
    @product = Product.find(params[:id])
    if @product.update_attributes(product_params)
      redirect_to products_path
    else
      render :edit
    end
  end

  private

  def product_params
    params.require(:product).permit!
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
token_field-2.0.0 spec/dummy/app/controllers/products_controller.rb