Sha256: d5371bfc2c9b20bc710a47ebe538ec5de602ec4321fda9923682b140e985a54c

Contents?: true

Size: 972 Bytes

Versions: 7

Compression:

Stored size: 972 Bytes

Contents

class BlogsController < ApplicationController
  before_action :set_blog, only: [:show, :edit, :update, :destroy]

  # GET /blogs
  def index
    @blogs = Blog.all
    respond_with(@blogs)
  end

  # GET /blogs/1
  def show
    respond_with(@blog)
  end

  # GET /blogs/new
  def new
    @blog = Blog.new
    respond_with(@blog)
  end

  # GET /blogs/1/edit
  def edit
  end

  # POST /blogs
  def create
    @blog = Blog.new(blog_params)

    @blog.save
    respond_with(@blog)
  end

  # PATCH/PUT /blogs/1
  def update
    @blog.update(blog_params)
    respond_with(@blog)
  end

  # DELETE /blogs/1
  def destroy
    @blog.destroy
    respond_with(@blog)
  end

  private
    # Use callbacks to share common setup or constraints between actions.
    def set_blog
      @blog = Blog.find(params[:id])
    end

    # Only allow a trusted parameter "white list" through.
    def blog_params
      params.require(:blog).permit(:subject, :body, :user, :release)
    end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
wobapphelpers-4.2.0 test/dummy/app/controllers/blogs_controller.rb
wobapphelpers-4.1.2 test/dummy/app/controllers/blogs_controller.rb
wobapphelpers-4.1.1 test/dummy/app/controllers/blogs_controller.rb
wobapphelpers-4.1.0 test/dummy/app/controllers/blogs_controller.rb
wobapphelpers-4.0.0 test/dummy/app/controllers/blogs_controller.rb
wobapphelpers-3.1.1 test/dummy/app/controllers/blogs_controller.rb
wobapphelpers-3.1.0 test/dummy/app/controllers/blogs_controller.rb