Rails 3 returning a HTTP 406 Not Acceptable?

我怕爱的太早我们不能终老 提交于 2019-11-28 18:09:15

Remove respond_to do |format| blocks. Because you are not specifying to what format are you responding, e.g. format.html { #your code here } . Check documentation of respond_to how to use it properly.

I had a similar error, my controller was only responding to JSON. I needed it to respond to HTML also for the tests to work (which only makes sense):

class AdsController < ApplicationController
  respond_to :json, :html

I received the error when trying to do: assert_redirected_to ad_url(ad)

I started having this issue after a deploy in production, even tough everything was working fine in development.

After some 15 minutes of wasted time, I finally found out that I had forgotten to commit some of the view files (like index.html.erb).

Using tail -f log/production.log on the server revealed: FATAL -- : ActionController::UnknownFormat (SomeController#index is missing a template for this request format and variant.

In development the error didn't happen because, obviously, the view file was present.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!