Sha256: b1266c1535a1172bdc1d5812875a8ffab5f6f3542a0e70738ac194d0c5b65d7b

Contents?: true

Size: 636 Bytes

Versions: 1

Compression:

Stored size: 636 Bytes

Contents

class AuthorizedController < InheritedResources::Base
  # Authorization
  authorize_resource

  rescue_from CanCan::AccessDenied do |exception|
    flash[:alert] = t('cancan.access_denied')
    redirect_to :back
  end

  # Responders
  respond_to :html, :js

  # Set the user locale
  before_filter :set_locale
  def set_locale
    I18n.locale = current_user.locale if current_user
  end

  # Resource setup
  protected
    def collection
      instance_eval("@#{controller_name.pluralize} ||= end_of_association_chain.accessible_by(current_ability, :list).paginate(:page => params[:page], :per_page => params[:per_page])")
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bookyt-0.0.1 app/controllers/authorized_controller.rb