Sha256: cfd4382cf6bc48a5ca464d6017540cdafddf237aabe92ef1ac7bb3995ff36af3

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

module Vellum
  class CategoriesController < ApplicationController
 
    # GET /categories
    def index
      @categories = Category.all
    end
  
    # GET /categories/1
    def show
      @category = Category.find(params[:id])
    end
  
    # GET /categories/new
    def new
      @category = Category.new
    end
  
    # GET /categories/1/edit
    def edit
      @category = Category.find(params[:id])
    end
  
    # POST /categories
    def create
      @category = Category.new(category_params)
  
      if @category.save
        redirect_to @category, :notice => 'Category was successfully created.'
      else
        render action => 'new'
      end
    end
  
    # PATCH/PUT /categories/1
    def update
      @category = Category.find(params[:id])
      if @category.update(category_params)
        redirect_to @category, :notice => 'Category was successfully updated.'
      else
        render action => 'edit'
      end
    end
  
    # DELETE /categories/1
    def destroy
      @category = Category.find(params[:id])
      @category.destroy
      redirect_to categories_url, :notice => 'Category was successfully destroyed.'
    end
  
    private 
      # Only allow a trusted parameter "white list" through.
      def category_params
        params.require(:category).permit(:name, :language)
      end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vellum-0.0.2 app/controllers/vellum/categories_controller.rb