Rails MissingTemplate由“GET * / *;”引起

时间:2015-02-25 17:45:22

标签: ruby-on-rails templates get routes options

有时,有线格式的请求会访问控制器:

Processing by HomeController#index as */*;

将发生500错误,详细信息如下:

ActionView::MissingTemplate (Missing template home/index, application/index with {:locale=>[:"zh-CN", :zh], :formats=>["*/*;"], :handlers       =>[:erb, :builder, :raw, :ruby, :jbuilder, :coffee, :haml]}. Searched in:

但是如果正常格式请求它会很好,例如:

Processing by HomeController#index as HTML
Processing by HomeController#index as text/vnd.wap.wml
Processing by HomeController#index as /
Processing by HomeController#index as */*
Processing by HomeController#index as application/x-wap-prov.browser-bookmarks

我认为最后一个字符';'是麻烦制造商,请告知如何避免此问题?

家庭控制器

before_filter :authenticate_user!, only: [:dashboard]
layout 'platform', only: [:dashboard]

  def index
    resource = User.new
    @users_count = User.count
    @customers_count = Customer.count
    @stores_count = Store.count
    @instances_count = Instance.count
    @orders_count = Order.count
    @orders_income = Order.sum(:amount).to_i
  end 

Rails版本

我正在使用Rails 4.0.4和ruby 2.0.0p353。

PS。

还想避免另一个路由错误,我甚至不知道我是否应该处理这种请求,如果我不需要,如何配置忽略或在route.rb中重定向它,请指教,理解!

INFO -- : Started OPTIONS "/" for 119.10.6.52 at 2015-02-23 05:59:39 +0800
FATAL -- : ActionController::RoutingError (No route matches [OPTIONS] "/"):

0 个答案:

没有答案