Sha256: ede404cecba1e0459cb5421bd05ba2107bd5337fd48187fc3b9a7dc37db3ec95
Contents?: true
Size: 1.38 KB
Versions: 3
Compression:
Stored size: 1.38 KB
Contents
require_dependency "blogr/application_controller" module Blogr class CategoriesController < ApplicationController before_action :set_category, only: [:show, :edit, :update, :destroy] def index @categories = Category.all @title = "Categories" end def show @title = @category.title end def new @category = Category.new @title = "New Category" end def edit @title = "Editing '#{@category.title}'" end def create @category = Category.new(category_params) if @category.save redirect_to category_path(@category), notice: 'Category was successfully created.' else render action: 'new' end end def update if @category.update(category_params) redirect_to category_path(@category), notice: 'Category was successfully updated.' else render action: 'edit' end end def destroy @category.destroy redirect_to categories_url, notice: 'Category was successfully destroyed.' end private # Use callbacks to share common setup or constraints between actions. def set_category @category = Category.find_by(permalink: params[:id]) end # Only allow a trusted parameter "white list" through. def category_params params.require(:category).permit(:title, :description) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
blogr-0.0.8 | app/controllers/blogr/categories_controller.rb |
blogr-0.0.7 | app/controllers/blogr/categories_controller.rb |
blogr-0.0.6 | app/controllers/blogr/categories_controller.rb |