class Alchemy::RoutingConstraints

Routing constraints for Alchemy’s strong catch all route.

Alchemy has a very strong catch all route. But we don’t want to handle all requests.

For instance we only want to handle html requests and don’t want to swallow the rails/info routes in development mode.

Constants

LOCALE_REGEXP

Public Instance Methods

matches?(request) click to toggle source
# File lib/alchemy/routing_constraints.rb, line 15
def matches?(request)
  @request = request
  @params = @request.params

  handable_format? && no_rails_route?
end

Private Instance Methods

handable_format?() click to toggle source

We only want html requests to be handled by us.

If an unknown format is requested we want to handle this, because it could be a legacy route that needs to be redirected.

# File lib/alchemy/routing_constraints.rb, line 29
def handable_format?
  @request.format.symbol.nil? || @request.format.html?
end
no_rails_route?() click to toggle source

We don’t want to handle the Rails info routes.

# File lib/alchemy/routing_constraints.rb, line 34
def no_rails_route?
  return true if !%w[development test].include?(Rails.env)

  !@params["urlname"].start_with?("rails/")
end