Sha256: 58b21905979ce00aaeb9d6d7ecc63e9ba2638d4f2e69e058a3051399d8157362

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

class Comfy::Admin::Blog::BlogsController < Comfy::Admin::Blog::BaseController

  before_action :build_blog,  :only => [:new, :create]
  before_action :load_blog,   :only => [:edit, :update, :destroy]

  def index
    @blogs = comfy_paginate(@site.blogs)
  end

  def new
    render
  end

  def edit
    render
  end

  def create
    @blog.save!
    flash[:success] = 'Blog created'
    redirect_to :action => :edit, :id => @blog
  rescue ActiveRecord::RecordInvalid
    flash.now[:error] = 'Failed to create Blog'
    render :action => :new
  end

  def update
    @blog.update_attributes!(blog_params)
    flash[:success] = 'Blog updated'
    redirect_to :action => :edit, :id => @blog
  rescue ActiveRecord::RecordInvalid
    flash.now[:error] = 'Failed to update Blog'
    render :action => :edit
  end

  def destroy
    @blog.destroy
    flash[:success] = 'Blog deleted'
    redirect_to :action => :index
  end

protected

  def build_blog
    @blog = @site.blogs.new(blog_params)
  end

  def blog_params
    params.fetch(:blog, {}).permit!
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
comfy_blog-1.12.3 app/controllers/comfy/admin/blog/blogs_controller.rb
comfy_blog-1.12.2 app/controllers/comfy/admin/blog/blogs_controller.rb