Sha256: eae104ffa98eeadfcbf83829ca877dcdb642131a83aa4a64719565f0d5aa889f

Contents?: true

Size: 749 Bytes

Versions: 7

Compression:

Stored size: 749 Bytes

Contents

module Prosperity
  class ApplicationController < ActionController::Base
    protected
    def set_error(model)
      flash[:error] = model.errors.full_messages.to_sentence
    end

    def render_json_error(msg, code)
      render json: {error: msg}, status: code
    end

    def strong_params?
      defined?(ActionController::StrongParameters)
    end

    def now
      @now ||= Time.now
    end

    def period
      params.fetch(:period, 'week')
    end

    def end_time 
      params[:end_time].present? ? Time.parse(params[:end_time].to_s) : now
    end

    def start_time
      params[:start_time].present? ? Time.parse(params[:start_time].to_s) : end_time - 3.months
    end

    helper_method :end_time, :start_time, :period
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
prosperity-0.0.8 app/controllers/prosperity/application_controller.rb
prosperity-0.0.7 app/controllers/prosperity/application_controller.rb
prosperity-0.0.6 app/controllers/prosperity/application_controller.rb
prosperity-0.0.5 app/controllers/prosperity/application_controller.rb
prosperity-0.0.4 app/controllers/prosperity/application_controller.rb
prosperity-0.0.3 app/controllers/prosperity/application_controller.rb
prosperity-0.0.2 app/controllers/prosperity/application_controller.rb