Sha256: 289b7ef4f55f83b12cb7644369cbf3f22ff2a3cb55fc4df9bcedf7c40b27a882

Contents?: true

Size: 1.06 KB

Versions: 43

Compression:

Stored size: 1.06 KB

Contents

class PostsController < ApplicationController
  before_action :set_post, only: [:show, :edit, :update, :destroy]

  # GET /posts
  def index
    @posts = Post.all
  end

  # GET /posts/1
  def show
  end

  # GET /posts/new
  def new
    @post = Post.new
  end

  # GET /posts/1/edit
  def edit
  end

  # POST /posts
  def create
    @post = Post.new(post_params)

    if @post.save
      redirect_to @post, notice: "Post was successfully created."
    else
      render :new
    end
  end

  # PATCH/PUT /posts/1
  def update
    if @post.update(post_params)
      redirect_to @post, notice: "Post was successfully updated."
    else
      render :edit
    end
  end

  # DELETE /posts/1
  def destroy
    @post.destroy
    redirect_to posts_url, notice: "Post was successfully destroyed."
  end

  private

  # Use callbacks to share common setup or constraints between actions.
  def set_post
    @post = Post.find(params[:id])
  end

  # Only allow a trusted parameter "white list" through.
  def post_params
    params.require(:post).permit(:title, :body, :author_id)
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
sapience-1.0.11 test_apps/rails/app/controllers/posts_controller.rb
sapience-1.0.10 test_apps/rails/app/controllers/posts_controller.rb
sapience-1.0.9 test_apps/rails/app/controllers/posts_controller.rb
sapience-1.0.8 test_apps/rails/app/controllers/posts_controller.rb
sapience-1.0.7 test_apps/rails/app/controllers/posts_controller.rb
sapience-1.0.6 test_apps/rails/app/controllers/posts_controller.rb
sapience-1.0.5 test_apps/rails/app/controllers/posts_controller.rb
sapience-1.0.4 test_apps/rails/app/controllers/posts_controller.rb
sapience-1.0.3 test_apps/rails/app/controllers/posts_controller.rb
sapience-1.0.2 test_apps/rails/app/controllers/posts_controller.rb
sapience-1.0.1 test_apps/rails/app/controllers/posts_controller.rb
sapience-1.0.0 test_apps/rails/app/controllers/posts_controller.rb
sapience-0.2.18 test_apps/rails/app/controllers/posts_controller.rb
sapience-0.2.17 test_apps/rails/app/controllers/posts_controller.rb
sapience-0.2.16 test_apps/rails/app/controllers/posts_controller.rb
sapience-0.2.15 test_apps/rails/app/controllers/posts_controller.rb
sapience-0.2.14 test_apps/rails/app/controllers/posts_controller.rb
sapience-0.2.13 test_apps/rails/app/controllers/posts_controller.rb
sapience-0.2.12 test_apps/rails/app/controllers/posts_controller.rb
sapience-0.2.11 test_apps/rails/app/controllers/posts_controller.rb