You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1015 B

8 years ago
7 years ago
7 years ago
8 years ago
  1. # frozen_string_literal: true
  2. class ApplicationController < ActionController::Base
  3. # Prevent CSRF attacks by raising an exception.
  4. # For APIs, you may want to use :null_session instead.
  5. protect_from_forgery with: :exception
  6. force_ssl if: "Rails.env.production? && ENV['LOCAL_HTTPS'] == 'true'"
  7. helper_method :current_account
  8. rescue_from ActionController::RoutingError, with: :not_found
  9. rescue_from ActiveRecord::RecordNotFound, with: :not_found
  10. before_action :store_current_location, except: :raise_not_found, unless: :devise_controller?
  11. def raise_not_found
  12. raise ActionController::RoutingError, "No route matches #{params[:unmatched_route]}"
  13. end
  14. private
  15. def store_current_location
  16. store_location_for(:user, request.url)
  17. end
  18. protected
  19. def not_found
  20. respond_to do |format|
  21. format.any { head 404 }
  22. end
  23. end
  24. def gone
  25. respond_to do |format|
  26. format.any { head 410 }
  27. end
  28. end
  29. def current_account
  30. current_user.try(:account)
  31. end
  32. end