Sha256: 0f7e5fd44d2089becc854c5cb9269533c57555f45d12efa88659a55ca88acbfc

Contents?: true

Size: 1.49 KB

Versions: 8

Compression:

Stored size: 1.49 KB

Contents

require 'cancan'
require 'state_machine'

module Pageflow
  class ApplicationController < ActionController::Base
    layout 'pageflow/application'

    # Prevent CSRF attacks by raising an exception.
    # For APIs, you may want to use :null_session instead.
    protect_from_forgery with: :exception

    include EditLocking

    rescue_from ActiveRecord::RecordNotFound do
      respond_to do |format|
        format.html { render :file => Rails.root.join('public/404.html'), :status => :not_found }
        format.any(:json, :css) { head :not_found }
      end
    end

    rescue_from CanCan::AccessDenied do |exception|
      respond_to do |format|
        format.html { redirect_to main_app.admin_root_path, :alert => t('unauthorized') }
        format.any(:json, :css) { head :forbidden }
      end
    end

    rescue_from StateMachine::InvalidTransition do |exception|
      respond_to do |format|
        format.html { redirect_to main_app.admin_root_path, :alert => t('invalid_transition') }
        format.json { head :bad_request }
      end
    end

    protected

    def current_ability
      @current_ability ||= Ability.new(current_user)
    end

    def after_sign_in_path_for(resource_or_scope)
      root_url(:protocol => 'http')
    end

    def after_sign_out_path_for(resource_or_scope)
      root_url(:protocol => 'http')
    end

    def prevent_ssl
      if request.ssl?
        redirect_to("http://#{request.host}#{request.fullpath}", :status => :moved_permanently)
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
pageflow-0.3.0 app/controllers/pageflow/application_controller.rb
pageflow-0.2.1 app/controllers/pageflow/application_controller.rb
pageflow-0.2.0 app/controllers/pageflow/application_controller.rb
pageflow-0.1.0 app/controllers/pageflow/application_controller.rb
pageflow-0.0.5 app/controllers/pageflow/application_controller.rb
pageflow-0.0.4 app/controllers/pageflow/application_controller.rb
pageflow-0.0.3 app/controllers/pageflow/application_controller.rb
pageflow-0.0.2 app/controllers/pageflow/application_controller.rb