Sha256: cf9653c6864d735b298693465d648464812f461e05cf8a5f8a9d4970a07aad53

Contents?: true

Size: 1.07 KB

Versions: 27

Compression:

Stored size: 1.07 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, :published)
    end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
cypress-on-rails-1.17.0 specs_e2e/rails_5_2/app/controllers/posts_controller.rb
cypress-on-rails-1.16.0 specs_e2e/rails_5_2/app/controllers/posts_controller.rb
cypress-on-rails-1.15.1 specs_e2e/rails_5_2/app/controllers/posts_controller.rb
cypress-on-rails-1.15.0 specs_e2e/rails_5_2/app/controllers/posts_controller.rb
cypress-on-rails-1.14.0 specs_e2e/rails_5_2/app/controllers/posts_controller.rb
cypress-on-rails-1.13.1 specs_e2e/rails_5_2/app/controllers/posts_controller.rb
cypress-on-rails-1.13.0 specs_e2e/rails_5_2/app/controllers/posts_controller.rb
cypress-on-rails-1.12.1 spec/integrations/rails_5_2/app/controllers/posts_controller.rb
cypress-on-rails-1.12.0 spec/integrations/rails_5_2/app/controllers/posts_controller.rb
cypress-on-rails-1.11.0 spec/integrations/rails_5_2/app/controllers/posts_controller.rb
cypress-on-rails-1.10.1 spec/integrations/rails_5_2/app/controllers/posts_controller.rb
cypress-on-rails-1.9.1 spec/integrations/rails_5_2/app/controllers/posts_controller.rb
cypress-on-rails-1.9.0 spec/integrations/rails_5_2/app/controllers/posts_controller.rb
cypress-on-rails-1.8.1 spec/integrations/rails_5_2/app/controllers/posts_controller.rb
cypress-on-rails-1.8.0 spec/integrations/rails_5_2/app/controllers/posts_controller.rb
cypress-on-rails-1.7.0 spec/integrations/rails_5_2/app/controllers/posts_controller.rb
cypress-on-rails-1.6.0 spec/integrations/rails_5_2/app/controllers/posts_controller.rb
cypress-on-rails-1.5.1 spec/integrations/rails_5_2/app/controllers/posts_controller.rb
cypress-on-rails-1.5.0 spec/integrations/rails_5_2/app/controllers/posts_controller.rb
cypress-on-rails-1.4.2 spec/integrations/rails_5_2/app/controllers/posts_controller.rb