Sha256: 64d1714c69c33546e97c70659c7a216de894f5faba3b1a1cefcae1064c11f8ea

Contents?: true

Size: 1.04 KB

Versions: 5

Compression:

Stored size: 1.04 KB

Contents

require_dependency "paginas/application_controller"
module Paginas
  class CategoriesController < ApplicationController
    before_action :set_category, only: [:show, :edit, :update, :destroy]
    def index
      @categories = Category.all
    end
    def show
    end
    def new
      @category = Category.new
    end
    def edit
    end
    def create
      @category = Category.new(category_params)
      if @category.save
        redirect_to @category, notice: 'Category was successfully created.'
      else
        render :new
      end
    end
    def update
      if @category.update(category_params)
        redirect_to @category, notice: 'Category was successfully updated.'
      else
        render :edit
      end
    end
    def destroy
      @category.destroy
      redirect_to categories_url, notice: 'Category was successfully destroyed.'
    end

    private
      def set_category
        @category = Category.find(params[:id])
      end
      def category_params
        params.require(:category).permit(:name, :description)
      end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
paginas-0.2.3.1 app/controllers/paginas/categories_controller.rb
paginas-0.2.3 app/controllers/paginas/categories_controller.rb
paginas-0.2.2 app/controllers/paginas/categories_controller.rb
paginas-0.2.1 app/controllers/paginas/categories_controller.rb
paginas-0.2.0 app/controllers/paginas/categories_controller.rb