Sha256: 33b04b3e866ac2dc1a5ecf99fea8e7f4c64acf5be9b203b5b2b2090c82eb16cf

Contents?: true

Size: 522 Bytes

Versions: 1

Compression:

Stored size: 522 Bytes

Contents

class DismissibleBlocksController < ApplicationController
  def create
    if current_user_available?
      unless current_user.dismissed_blocks.include?(block)
        current_user.dismissed_blocks.push(block)
        current_user.save!
      end
      render json: {}, status: :ok
    else
      render json: {}, status: :unprocessable_entity
    end
  end

  private

    def current_user_available?
      current_user && current_user.try(:dismissed_blocks)
    end

    def block
      params[:block].to_s
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dismissible_blocks-2.0.4 app/controllers/dismissible_blocks_controller.rb