0

我正在尝试从我的 html.erb 文件中呈现我的 HAML 部分(_my_partial.haml):

<%= render "shared/my_partial" %>

并得到:

ActionView::Template::Error (Missing partial shared/my_partial with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee]}。搜索在:

我注意到 :handlers 不包含haml

在 Gemfile 我有

group :assets do
  gem 'haml-rails'
  ..
end

需要注意的一件事:这只发生在生产环境中,例如当我使用时

RAILS_ENV production rails s

我怎样才能将它添加到那里,以便稍后尝试找到部分?

4

2 回答 2

2

It comes out that rendering HAML from ERB can be difficult :) Luckily, render function has :handlers parameter. So the following will solve the mentioned problem:

<%= render "shared/my_partial", :handlers => [:haml] %> 
于 2014-02-16T22:46:55.777 回答
2

搬出。gem 'haml-rails'_ group :assets它应该可以解决问题。

于 2014-02-16T22:04:53.383 回答