# Rails 3 and Haml breaks ERB

**URL:** <https://www.ruby-forum.com/t/rails-3-and-haml-breaks-erb/185274>\
**Category:** Rails\
**Created:** [March 17, 2010, 10:26am UTC](https://www.ruby-forum.com/t/rails-3-and-haml-breaks-erb/185274 "2010-03-17T10:26:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sigvei](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ac8455/32.png) [@sigvei](https://www.ruby-forum.com/u/sigvei)\
**Post date:** [March 17, 2010, 10:26am UTC](https://www.ruby-forum.com/t/rails-3-and-haml-breaks-erb/185274/1 "2010-03-17T10:26:48Z")

</div>

I installed rails 3.0 beta and haml 2.2.21 and created a new project,  
and initalized haml for it. I then generate a standard ERb scaffold  
(rails scaffold Person name:string) and add “gem ‘haml’” to the  
Gemfile.

When i run the server and head to People#new, I get the following:

```
undefined method `html_safe' for nil:NilClass

Extracted source (around line #1):

1: <% form_for(@person) do |f| %>
2: <%= f.error_messages %>
3:
4:

I am really at a loss here. In a more complex project, where the  
layout is rendered with haml and the form with ERb, the application  
trace shows that form\_for is dispatched to Haml:

```
/Library/Ruby/Gems/1.8/gems/activesupport-3.0.0.beta/lib/
active_support/whiny_nil.rb:49:in `method_missing'
    haml (2.2.21) lib/haml/util.rb:216:in `html_safe'
    haml (2.2.21) lib/haml/helpers/xss_mods.rb:118:in `form_for'
    app/views/schools/_form.html.erb:1:in
`_render_template_1729594521_2187273160_1077630'
    /Library/Ruby/Gems/1.8/gems/actionpack-3.0.0.beta/lib/action_view/
template.rb:40:in `send'
    /Library/Ruby/Gems/1.8/gems/actionpack-3.0.0.beta/lib/action_view/
template.rb:40:in `render'
```

But I was not able to reproduce that trace with the clean project,  
which only gives me a trace from within the app (for some reason). If  
I remove haml from Gemfile and plugins, it renders without problems.

Here’s the relevant parts of my gem list:  
actionmailer (3.0.0.beta, 2.3.5, 2.3.4, 2.3.2, 2.3.1, 2.2.2, 1.3.6)  
actionpack (3.0.0.beta, 2.3.5, 2.3.4, 2.3.2, 2.3.1, 2.2.2, 1.13.6)  
actionwebservice (1.2.6)  
activemodel (3.0.0.beta)  
activerecord (3.0.0.beta, 2.3.5, 2.3.4, 2.3.2, 2.3.1, 2.2.2, 1.15.6)  
activeresource (3.0.0.beta, 2.3.5, 2.3.4, 2.3.2, 2.3.1, 2.2.2)  
activesupport (3.0.0.beta, 2.3.5, 2.3.4, 2.3.2, 2.3.1, 2.2.2, 1.4.4)  
arel (0.3.1, 0.2.1)  
builder (2.1.2)  
bundler (0.9.11)  
configuration (1.1.0)  
crack (0.1.7, 0.1.6, 0.1.4)  
daemons (1.0.10)  
erubis (2.6.5)  
gem\_plugin (0.2.3)  
gemcutter (0.5.0)  
haml (2.2.21, 2.2.16, 2.2.14, 2.0.6, 2.0.5)  
mail (2.1.3)  
memcache-client (1.8.0, 1.7.8)  
mongrel (1.1.5)  
rack (1.1.0, 1.0.1, 1.0.0, 0.9.1, 0.4.0)  
rack-mount (0.6.1, 0.4.7, 0.4.0)  
rack-test (0.5.3)  
rails (3.0.0.beta, 2.3.5, 2.3.4, 2.3.2, 2.3.1, 2.2.2, 1.2.6)  
railties (3.0.0.beta)  
rake (0.8.7, 0.8.3)  
RedCloth (4.2.3, 4.2.2, 4.1.9, 4.1.1)  
rubygems-update (1.3.6, 1.3.5, 1.3.1)  
sqlite3-ruby (1.2.5, 1.2.4)  
thor (0.13.4)  
tzinfo (0.3.17)  
xml-simple (1.0.12)
```

---

<div class="post-metadata">

**Author:** ![sigvei](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ac8455/32.png) [@sigvei](https://www.ruby-forum.com/u/sigvei)\
**Post date:** [March 17, 2010, 10:43am UTC](https://www.ruby-forum.com/t/rails-3-and-haml-breaks-erb/185274/2 "2010-03-17T10:43:11Z")

</div>

On Mar 17, 10:25 am, sigvei [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I installed rails 3.0 beta and haml 2.2.21 and created a new project,  
> and initalized haml for it. I then generate a standard ERb scaffold  
> (rails scaffold Person name:string) and add “gem ‘haml’” to the  
> Gemfile.
> 
> rack-mount (0.6.1, 0.4.7, 0.4.0)

For the record, I have now also tried with rack-mount 0.4.0 (ie.  
removing rack-mount 0.4.7), and it made no difference.
