Methods for limiting the Rails render format to html

后端 未结 5 2014
没有蜡笔的小新
没有蜡笔的小新 2020-12-09 11:18

I have a Rails 2.1.2 site that only has html templates e.g. jobs.html.erb, so when I request a restful resource:

www.mysite.com/jobs/1

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-09 11:48

    I was getting non-sensical requests for image format on HTML files, triggerring a 500 with MissingTemplate. I edicted the following at the end of my action:

    def show
      # [...]
      respond_to :html
    end
    

    And now instead of getting error reports, we emit a 406 to that mischievious requester.

提交回复
热议问题