我使用rails版本3.2.12,并使用。erb模板为我的视图。
现在我想开始使用haml模板。
我将haml和haml-rails添加到gem文件中,并安装了bundle。
Using haml (4.0.0)
Installing haml-rails (0.4)
我已经做了一个模拟应用程序。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和一切工作就像它应该工作。