Sha256: 12a0b8f9e22cc172e02e89411d1db82398c317554418260bb7d5545db5ef3106

Contents?: true

Size: 503 Bytes

Versions: 6

Compression:

Stored size: 503 Bytes

Contents

class EdgeCasesController < ApplicationController
  def show
    @post = Post.find_or_initialize_by(id: params[:post_id])
    render action: params[:id]
  end

  def update
    @post = Post.new(post_params)
    if @post.save
      redirect_to({ id: params[:id], post_id: @post.id }, notice: "Post created!")
    else
      flash.now.alert = @post.errors.full_messages.join("<br>")
      render action: params[:id]
    end
  end

  private

  def post_params
    params.require(:post).permit!
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
bard-file_field-0.1.5 dummy/app/controllers/edge_cases_controller.rb
bard-file_field-0.1.4 dummy/app/controllers/edge_cases_controller.rb
bard-file_field-0.1.3 dummy/app/controllers/edge_cases_controller.rb
bard-file_field-0.1.2 dummy/app/controllers/edge_cases_controller.rb
bard-file_field-0.1.1 dummy/app/controllers/edge_cases_controller.rb
bard-file_field-0.1.0 dummy/app/controllers/edge_cases_controller.rb