Sha256: ba88ba8c9e41bacbc42d743a7c86452a1442505615f947be1060e9e33ed3ba14

Contents?: true

Size: 1017 Bytes

Versions: 1

Compression:

Stored size: 1017 Bytes

Contents

module Dataclips
  class ClipsController < ApplicationController
    def show
      @clip_id = params[:clip_id]

      begin
        initialize_clip(@clip_id)
      rescue
        raise ActionController::RoutingError.new('Not Found')
      end

      @headers = localize_headers(@clip_id, @schema.keys)

      @clip = @klass.new params.slice(*@variables.keys)

      respond_to do |format|
        format.html do
          begin
            require_parameters
          rescue ActionController::ParameterMissing => e
            @error = e
            render :edit
          end
        end

        format.json do
          begin
            process_json(@clip, params[:page])
          rescue ActiveRecord::StatementInvalid => e
            render json: e.message, status: :unprocessable_entity
          end
        end
      end
    end

    def edit; end

    private

    def require_parameters
      @variables.keys.map(&:to_sym).each do |variable|
        params.require(variable)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dataclips-0.0.1 app/controllers/dataclips/clips_controller.rb