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