Sha256: e643ff07a7b7b95e19bf858f43a032bec9dcbbd3d68138e6173226b8ba95fe33

Contents?: true

Size: 1.08 KB

Versions: 13

Compression:

Stored size: 1.08 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 action: 'new'
    end
  end

  # PATCH/PUT /posts/1
  def update
    if @post.update(post_params)
      redirect_to @post, notice: 'Post was successfully updated.'
    else
      render action: '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, :file)
    end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
uploadcare-rails-1.2.1 spec/dummy/app/controllers/posts_controller.rb
uploadcare-rails-1.2.0 spec/dummy/app/controllers/posts_controller.rb
uploadcare-rails-1.2.0.pre.alpha3 spec/dummy/app/controllers/posts_controller.rb
uploadcare-rails-1.2.0.pre.alpha spec/dummy/app/controllers/posts_controller.rb
uploadcare-rails-1.1.1 spec/dummy/app/controllers/posts_controller.rb
uploadcare-rails-1.1.0 spec/dummy/app/controllers/posts_controller.rb
uploadcare-rails-1.0.6 spec/dummy/app/controllers/posts_controller.rb
uploadcare-rails-1.0.5 spec/dummy/app/controllers/posts_controller.rb
uploadcare-rails-1.0.4 spec/dummy/app/controllers/posts_controller.rb
uploadcare-rails-1.0.3 spec/dummy/app/controllers/posts_controller.rb
uploadcare-rails-1.0.2 spec/dummy/app/controllers/posts_controller.rb
uploadcare-rails-1.0.1 spec/dummy/app/controllers/posts_controller.rb
uploadcare-rails-1.0.0.rc4 spec/dummy/app/controllers/posts_controller.rb