简体   繁体   中英

Missing partial when using curl for ComfortableMexicanSofa page

I've created a partial for use in my CMS page at:

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

My CMS page looks like this:

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

When I call this from the browser (ie, Chrome) it works fine. Also when I go incognito (to ensure there's no cookies being sent)

calling my test page from curl:

curl "http://localhost:5000/test" returns

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|

I'd expect curl to return the same results.

Update: The error occurs when Accept: text/html is ommitted from the curl statement.

My solution for now was to modify the CMS gem to explicitly use :formats => [:html] in the partial tag, and then specify the full path (including html.haml) of the partial like so:

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

A branch where this fix is here:

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

I've also filed a Github issue

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM