我使用的是 Rails 版本 3.2.12,并且在我的 View 中使用 .erb 模板。
现在我想开始使用 haml 模板。
我将 haml 和 haml-rails 添加到 gem 文件中并安装了该 bundle 。
Using haml (4.0.0)
Installing haml-rails (0.4)
我制作了一个模型 application.html.haml
!!! 5
%html
%head
%title Rotten Potatoes!
= stylesheet_link_tag 'application'
= javascript_include_tag 'application'
= csrf_meta_tags
%body
= yield
然后我将 application_controller.rb 更改为
class ApplicationController < ActionController::Base
layout "application"
protect_from_forgery
include SessionsHelper
end
当我运行此命令时,我收到以下错误消息: 缺少带有 {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee]} 的模板布局/应用程序。搜索位置:*“/home/coen/Desktop/rails_project/sample_app/app/views”
似乎 haml 处理程序未安装。
我怎样才能做到这一点?
最佳答案
那么,您重新启动了开发服务器吗?在 Gemfile 中添加 gem 后要做的事情非常重要。
顺便说一句。我一直使用 haml,但从未使用过 'haml-rails'。当我开始新项目时,我所做的唯一一件事就是将“gem 'haml'”添加到 Gemfile 中,一切都会像预期的那样工作。
关于ruby-on-rails - application.html.haml 未呈现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15466701/