Sha256: 85a432319e4c2af6ead1998526b4eae6fc1a91766a112e78f927084f4f38d1cb

Contents?: true

Size: 747 Bytes

Versions: 1

Compression:

Stored size: 747 Bytes

Contents

module TmLyn
  class CategoriesController < ApplicationController
    def index
      @cats = Category.all
    end
    def new
      @cat = Category.new
    end
    def create
      @cat = Category.new(cat_params)
      if @cat.save
        redirect_to categories_path, notice:"Category created"
      else
        render :new, status: :unprocessable_entity
      end
    end
    def edit
      @cat = Category.find(params[:id])
    end
    def update
      @cat = Category.find(params[:id])
      if @cat.update(cat_params)
        redirect_to categories_path, notice:"Category updated successfully"
      else
        render :edit
      end
    end

    private
    def cat_params
      params.require(:category).permit(:name)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tm_lyn-0.1.0 app/controllers/tm_lyn/categories_controller.rb