Ruby on rails 无线路匹配的rails 410
当有人以错误的路线访问我的站点时,rails会以Ruby on rails 无线路匹配的rails 410,ruby-on-rails,ruby,Ruby On Rails,Ruby,当有人以错误的路线访问我的站点时,rails会以404代码和错误进行响应 ActionController::路由错误没有匹配的路由 我是否可以用410code-on-the-rails's error代替404?我不知道你为什么想作为一个(消失了的)是为了一个曾经可用但不再可用的资源 如果你按照答案去做,那么它就允许你去做 只需将render_404方法更改为 def render_404 if /(jpe?g|png|gif)/i === request.path render
404
代码和错误进行响应
ActionController::路由错误没有匹配的路由
我是否可以用
410
code-on-the-rails's error代替404
?我不知道你为什么想作为一个(消失了的)是为了一个曾经可用但不再可用的资源
如果你按照答案去做,那么它就允许你去做
只需将render_404方法更改为
def render_404
if /(jpe?g|png|gif)/i === request.path
render :text => "404 Not Found", :status => 410 # Change the status here
else
render :template => "shared/404", :layout => 'application', :status => 410 #and here
end
end
如果仍要指向公用文件夹中的404.html:
render :file => "#{Rails.root}/public/404.html"
我不知道为什么你会想作为一个(过去的)是为一个资源,曾经是可用的,但不再 如果你按照答案去做,那么它就允许你去做 只需将render_404方法更改为
def render_404
if /(jpe?g|png|gif)/i === request.path
render :text => "404 Not Found", :status => 410 # Change the status here
else
render :template => "shared/404", :layout => 'application', :status => 410 #and here
end
end
如果仍要指向公用文件夹中的404.html:
render :file => "#{Rails.root}/public/404.html"
404表示url不正确。410表示删除的内容。404表示错误的url。410将用于删除的内容。