Sha256: a84b26c9edd3072256118912e320587236e0eb38c02e5f15fcb9aeb813fac973

Contents?: true

Size: 638 Bytes

Versions: 7

Compression:

Stored size: 638 Bytes

Contents

require_dependency "annex/application_controller"

module Annex
  class BlocksController < ApplicationController

    # POST /annex/blocks
    def create
      @block = Block.where(:route => params[:route]).first_or_create
      @block.content ||= {}

      params[:content].keys.each do |key|
        @block.content[key] = params[:content][key]
      end

      if @block.save
        render json: {status: :success}, status: :ok
      else
        render json: @block.errors, status: :unprocessable_entity
      end
    end

    private

      def block_params
        params.require(:user).permit(:route, :content)
      end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
annex-cms-0.2.1 app/controllers/annex/blocks_controller.rb
annex-cms-0.2.0 app/controllers/annex/blocks_controller.rb
annex-cms-0.1.8 app/controllers/annex/blocks_controller.rb
annex-cms-0.1.7 app/controllers/annex/blocks_controller.rb
annex-cms-0.1.5 app/controllers/annex/blocks_controller.rb
annex-cms-0.1.2 app/controllers/annex/blocks_controller.rb
annex-cms-0.1.0 app/controllers/annex/blocks_controller.rb