Sha256: ed20a865a4328c417a2ce94181592b1959fb096ee3cf6d9f6b10b9d718602cfb

Contents?: true

Size: 1.47 KB

Versions: 13

Compression:

Stored size: 1.47 KB

Contents

class ApplicationController < ActionController::Base
  protect_from_forgery

  rescue_from CanCan::AccessDenied, :with => :render_403
  rescue_from ActiveRecord::RecordNotFound, :with => :render_404

  enju_biblio
  enju_library

  private
  def render_403
    return if performed?
    if user_signed_in?
      respond_to do |format|
        format.html {render :template => 'page/403', :status => 403}
        format.xml {render :template => 'page/403', :status => 403}
        format.json
      end
    else
      respond_to do |format|
        format.html {redirect_to new_user_session_url}
        format.xml {render :template => 'page/403', :status => 403}
        format.json
      end
    end
  end

  def render_404
    return if performed?
    respond_to do |format|
      format.html {render :template => 'page/404', :status => 404}
      format.mobile {render :template => 'page/404', :status => 404}
      format.xml {render :template => 'page/404', :status => 404}
      format.json
    end
  end

  def access_denied
    raise CanCan::AccessDenied
  end

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

  def solr_commit
    Sunspot.commit
  end

  def move_position(resource, direction, redirect = true)
    if ['higher', 'lower'].include?(direction)
      resource.send("move_#{direction}")
      if redirect
        redirect_to url_for(:controller => resource.class.to_s.pluralize.underscore)
        return
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
enju_library-0.1.0.pre12 spec/dummy/app/controllers/application_controller.rb
enju_library-0.1.0.pre11 spec/dummy/app/controllers/application_controller.rb
enju_library-0.1.0.pre10 spec/dummy/app/controllers/application_controller.rb
enju_library-0.1.0.pre9 spec/dummy/app/controllers/application_controller.rb
enju_library-0.1.0.pre8 spec/dummy/app/controllers/application_controller.rb
enju_library-0.1.0.pre7 spec/dummy/app/controllers/application_controller.rb
enju_library-0.1.0.pre6 spec/dummy/app/controllers/application_controller.rb
enju_library-0.1.0.pre5 spec/dummy/app/controllers/application_controller.rb
enju_library-0.1.0.pre4 spec/dummy/app/controllers/application_controller.rb
enju_library-0.1.0.pre3 spec/dummy/app/controllers/application_controller.rb
enju_library-0.1.0.pre2 spec/dummy/app/controllers/application_controller.rb
enju_library-0.1.0.pre spec/dummy/app/controllers/application_controller.rb
enju_library-0.0.2 spec/dummy/app/controllers/application_controller.rb