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.

42 lines
984 B

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