Skip to content

Instantly share code, notes, and snippets.

@piersadrian
Last active December 25, 2015 07:19
Show Gist options
  • Save piersadrian/6938745 to your computer and use it in GitHub Desktop.
Save piersadrian/6938745 to your computer and use it in GitHub Desktop.
# routes.rb
constraints format: "html" do
get "*path", to: "angular#index", as: "angular"
end
# angular_controller.rb
class AngularController < ActionController::Base
VALID_PATHS = %w(/community /store /challenges /admin/health /admin/activities /admin/challenges /admin/budget)
before_action :verify_path!
...
private
def verify_path!
unless VALID_PATHS.include?(request.path)
raise ActionController::RoutingError.new("Path not found")
end
end
end
# using the route helper
angular_path("admin/challenges")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment