Sha256: 508c5dcdc53d99832afacfd1e8513d2eff6bf5b946115c71e9b236809b39e0d5

Contents?: true

Size: 1.98 KB

Versions: 20

Compression:

Stored size: 1.98 KB

Contents

module IshManager
  class ApplicationController < ActionController::Base
    # protect_from_forgery :with => :exception, :prepend => true
    before_action :set_current_ability
    before_action :set_changelog
    check_authorization
    rescue_from ::CanCan::AccessDenied, :with => :access_denied

    def home
      authorize! :home, IshManager::Ability
      render 'home'
    end

    #
    # private
    #
    private

    def set_changelog
      @version = Gem.loaded_specs['ish_manager'].version.to_s
    end

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

    def set_lists
      @sites_list = Site.all.list
      @cities_list = City.list
      @venues_list = Venue.all.list
      @reports_list = Report.all.list
      @galleries_list = Gallery.all.list
      @videos_list = Video.all.list
      @user_profiles_list = IshModels::UserProfile.all.list
      @tags_list = Tag.list
    end

    def access_denied exception
      store_location_for :user, request.path
      redirect_to user_signed_in? ? root_path : Rails.application.routes.url_helpers.new_user_session_path, :alert => exception.message
    end

    def pp_errors err
      err
    end

    def puts! a, b=''
      puts "+++ +++ #{b}"
      puts a.inspect
    end

    def update_profile_pic
      return unless params[:photo]
      @photo = Photo.new :photo => params[:photo]
      @photo.user_profile = @current_user.profile
      flag = @photo.save
      @resource.profile_photo = @photo
      flagg = @resource.save
      if flag && flagg
        flash[:notice] = 'Success'
      else
        flash[:alert] = "No Luck. #{@photo.errors.messages} #{@resource.errors.messages}"
      end
      # redirect_to resource_path( @resource )
    end

    def resource_path resource
      case resource.class.name
      when 'City'
        city_path( resource.id )
      when 'Event'
        event_path( resource.id )
      when 'Venue'
        venue_path( resource.id )
      end
    end

  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
ish_manager-0.1.8.249 app/controllers/ish_manager/application_controller.rb
ish_manager-0.1.8.248 app/controllers/ish_manager/application_controller.rb
ish_manager-0.1.8.247 app/controllers/ish_manager/application_controller.rb
ish_manager-0.1.8.246 app/controllers/ish_manager/application_controller.rb
ish_manager-0.1.8.245 app/controllers/ish_manager/application_controller.rb
ish_manager-0.1.8.244 app/controllers/ish_manager/application_controller.rb
ish_manager-0.1.8.243 app/controllers/ish_manager/application_controller.rb
ish_manager-0.1.8.242 app/controllers/ish_manager/application_controller.rb
ish_manager-0.1.8.241 app/controllers/ish_manager/application_controller.rb
ish_manager-0.1.8.239 app/controllers/ish_manager/application_controller.rb
ish_manager-0.1.8.238 app/controllers/ish_manager/application_controller.rb
ish_manager-0.1.8.237 app/controllers/ish_manager/application_controller.rb
ish_manager-0.1.8.236 app/controllers/ish_manager/application_controller.rb
ish_manager-0.1.8.235 app/controllers/ish_manager/application_controller.rb
ish_manager-0.1.8.234 app/controllers/ish_manager/application_controller.rb
ish_manager-0.1.8.233 app/controllers/ish_manager/application_controller.rb
ish_manager-0.1.8.232 app/controllers/ish_manager/application_controller.rb
ish_manager-0.1.8.231 app/controllers/ish_manager/application_controller.rb
ish_manager-0.1.8.230 app/controllers/ish_manager/application_controller.rb
ish_manager-0.1.8.229 app/controllers/ish_manager/application_controller.rb