我有一个行动,服务我的主页.当正常访问(即通过Web浏览器中的用户)时,它工作正常,但是当被特定的网页抓取工具访问时,会引发以下错误:
A ActionView::MissingTemplate occurred in tags#promoted: Missing template tags/promoted with {:handlers=>[:erb,:rjs,:builder,:rhtml,:rxml],:formats=>["text/*"],:locale=>[:en,:en]} in view paths "/Apps/accounts/app/views","/usr/local/rvm/gems/ruby-1.9.2-p180@accounts/gems/devise-1.3.0/app/views" actionpack (3.0.4) lib/action_view/paths.rb:15:in `find'@H_404_3@看来,机器人正在尝试获取文本/ *格式,没有模板,这是有道理的,所以我尝试在我的操作中执行以下操作:
def promoted request.format = :html #force html to avoid causing missing template errors # more action stuff.... end@H_404_3@实质上,我试图强制请求的格式为html,所以它服务于HTML模板.