Sha256: 7e50500fc582c0389439b3761763936b30a038a9e035f4ab7ac056238008f1cd

Contents?: true

Size: 881 Bytes

Versions: 6

Compression:

Stored size: 881 Bytes

Contents

module Dashing
  class DashboardsController < ApplicationController

    before_filter :check_dashboard_name, only: :show

    rescue_from ActionView::MissingTemplate, with: :template_not_found

    def index
      render file: dashboard_path(Dashing.config.default_dashboard || Dashing.first_dashboard || ''), layout: Dashing.config.dashboard_layout_path
    end

    def show
      render file: dashboard_path(params[:name]), layout: Dashing.config.dashboard_layout_path
    end

    private

    def check_dashboard_name
      raise 'bad dashboard name' unless params[:name] =~ /\A[a-zA-z0-9_\-]+\z/
    end

    def dashboard_path(name)
      Rails.root.join(Dashing.config.dashboards_views_path, name)
    end

    def template_not_found
      raise "Count not find template for dashboard '#{params[:name]}'. Define your dashboard in #{dashboard_path('')}"
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
dashing-rails-2.2.0 app/controllers/dashing/dashboards_controller.rb
dashing-rails-2.1.1 app/controllers/dashing/dashboards_controller.rb
dashing-rails-2.1.0 app/controllers/dashing/dashboards_controller.rb
dashing-rails-2.0.2 app/controllers/dashing/dashboards_controller.rb
dashing-rails-2.0.1 app/controllers/dashing/dashboards_controller.rb
dashing-rails-2.0.0 app/controllers/dashing/dashboards_controller.rb