Sha256: 860c5a03f1dc6f02411596466a3b5e2888f5536d555696e8fe085e5f90fa1e21

Contents?: true

Size: 542 Bytes

Versions: 4

Compression:

Stored size: 542 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
      respond_to?(:current_user) && current_user.respond_to?(:dismissed_blocks)
    end

    def block
      params[:block].to_s
    end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dismissible_blocks-2.0.3 app/controllers/dismissible_blocks_controller.rb
dismissible_blocks-2.0.2 app/controllers/dismissible_blocks_controller.rb
dismissible_blocks-2.0.1 app/controllers/dismissible_blocks_controller.rb
dismissible_blocks-2.0.0 app/controllers/dismissible_blocks_controller.rb