1

我创建了一个部分用于我的 CMS 页面:

/app/views/users/_register_home_page.html.haml

我的 CMS 页面如下所示:

{{ cms:partial:/users/register_home_page }}

当我从浏览器(即 Chrome)调用它时,它工作正常。另外,当我隐身时(以确保没有发送 cookie)

从 curl 调用我的测试页面:

curl "http://localhost:5000/test" 返回

ActionView::MissingTemplate at /
================================

> Missing partial users/_register_home_page with {:locale=>[:en], :formats=>[:all], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :haml]}. Searched in:
  * "/Users/doug/dev/my-rails-app/app/views"

actionview (4.1.7) lib/action_view/path_set.rb, line 46
-------------------------------------------------------


   41           end
   42         METHOD
   43       end
   44   
   45       def find(*args)
>  46         find_all(*args).first || raise(MissingTemplate.new(self, *args))
   47       end
   48   
   49       def find_all(path, prefixes = [], *args)
   50         prefixes = [prefixes] if String === prefixes
   51         prefixes.each do |prefix|

我希望 curl 返回相同的结果。

更新:Accept: text/html从 curl 语句中省略时会发生错误。

4

1 回答 1

0

我现在的解决方案是修改 CMS gem 以:formats => [:html]在部分标记中显式使用,然后指定部分的完整路径(包括 html.haml),如下所示:

{{ cms:partial:/users/register_home_page.html.haml }}

此处修复的分支:

https://github.com/mvcodeclub/comfortable-mexican-sofa

我还提交了一个 Github 问题

于 2014-11-13T03:33:50.187 回答