在控制器规范中,我可以像这样设置http接受标头:
request.accept = "application/json"
Run Code Online (Sandbox Code Playgroud)
但在请求规范中,"请求"对象为零.那我怎么能在这里做呢?
我想将http接受标头设置为json的原因是我可以这样做:
get '/my/path'
Run Code Online (Sandbox Code Playgroud)
而不是这个
get '/my/path.json'
Run Code Online (Sandbox Code Playgroud) 我在网站上启动Google Crawler时遇到此错误:
错误信息:
ActionView :: MissingTemplate:缺少模板home/index,带有{:locale => [:fr],:formats => ["image/*"]的应用程序/索引,:handlers => [:erb,:builder,:haml ]}.搜索:*"/ home/custodir/apps/default/releases/32/app/views"*"/ home /custodir /apps/default/shared/bundle/ruby/2.0.0/gems/fixitor-4.0.10/app/views"*"/ home/custodir /apps/default/shared/bundle/ruby/2.0.0/gems/rails_admin-0.4.9/app/views"*"/ home/custodir/apps/default/shared /bundle/ruby/2.0.0/gems/kaminari-0.15.1/app/views"*"/ home/custodir /apps/default/shared/bundle/ruby/2.0.0/gems/devise-2.1.4 /应用程序/视图"
研究SO:
我注意到这3个相关问题: ActionView :: MissingTemplate - >我没有使用HAML
ActionView :: MissingTemplate:缺少模板 - >不相关
Googlebot收到现有模板的模板错误 - >尝试了gem"rails_fix_google_bot_accept"没有区别.
更多细节:
Errbit说可能的错误: 88.4%
ActionView :: MissingTemplate:缺少模板home/index,带有{:locale => [:fr],:formats => ["image/*"]的应用程序/索引,:handlers => [:erb,:builder,:haml ]}.搜索:*"/ home/custodir/apps/default/releases/30/app/views"*"/ home/custodir /apps/default/shared/bundle/ruby/2.0.0/gems/fixitor-4.0.10/app/views"*"/ home/custodir /apps/default/shared/bundle/ruby/2.0.0/gems/rails_admin-0.4.9/app/views"*"/ home/custodir/apps/default/shared /bundle/ruby/2.0.0/gems/kaminari-0.15.1/app/views"*"/ home/custodir /apps/default/shared/bundle/ruby/2.0.0/gems/devise-2.1.4 /应用程序/视图"
7.4%
ActionView :: MissingTemplate:缺少模板home/index,application/index with {:locale => [:fr],:formats => [:css],:handlers => [:erb,:builder,:haml]}.搜索:*"/ home/custodir/apps/default/releases/30/app/views"*"/ home/custodir /apps/default/shared/bundle/ruby/2.0.0/gems/fixitor-4.0.10/app/views"*"/ home/custodir /apps/default/shared/bundle/ruby/2.0.0/gems/rails_admin-0.4.9/app/views"*"/ home/custodir/apps/default/shared …