I have a relatively large website, and all day everyday it gets hit with requests that are irrelevant from all sorts of IP addresses. A common one is example.com/home.zip
.
This hits my Home controller, index action {"controller"=>"home", "action"=>"index", "format"=>"zip"}
. Currently, it causes a 500 error:
Missing template home/index, application/index with {:locale=>[:en], :formats=>[:zip], :handlers=>[:erb, :builder, :arb]}
I imagine the graceful way of handling it is a 404. The closest I've come to a solution is this:
respond_to do |format|
format.html
format.any { redirect_to :foo }
end
Except of redirect_to :foo
I would do render file: "#{Rails.root}/public/404.html", status: 404
. Am I on the right track?
Aucun commentaire:
Enregistrer un commentaire