Answer the question
In order to leave comments, you need to log in
How to make an exception in routing in rails 3
There is a routing specified at the very end
match "/:url" => "main#article", as: :article
Answer the question
In order to leave comments, you need to log in
It's pretty simple, routes.rb:
match "/favicon.ico" => "tools#favicon"
match "/:url" => "main#article", as: :article, constraints: DoesntMatch.new(path:
class ToolsController < ApplicationController
def favicon
data = File.open("public/favicon_test.ico", "rb").read
send_data(data, :filename => "favicon.ico", :type => "image/png")
end
end
not to bring such requests to the app-server and give them to the proxy server?
class DoesntMatch
def initialize(options)
@options = options
end
def matches?(request)
@options.inject(true) { |m, (k,v)|
m && (request.send(k) !~ v)
}
end
end
match "/:url" => "main#article", as: :article, constraints: DoesntMatch.new(path: /^\/favicon\.ico/)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question