I’m following this tutorial (http://ruby.railstutorial.org/chapters/sign-up#sec:signup_form). However, when code in Listing 7.23 (converted to haml)
=if @user.errors.any?
%div{:id => "error_explanation"}
%div{:class=>"alert alert-error"}
il modulo contiene errori
%ul
= @user.errors.full_messages.each do |msg|
%li
= msg
I end up with a double printout: the expected one, followed by a sort of printout of the variables
Name can't be blank
Password is too long (maximum is 15 characters)
["Name can't be blank", "Password is too long (maximum is 15 characters)"]
<h1>Registrazione nuovo utente</h1> <div id='error_explanation'> <div class='alert alert-error'> il modulo contiene errori <ul> <li> Name can't be blank </li> <li> Password is too long (maximum is 15 characters) </li> ["Name can't be blank", "Password is too long (maximum is 15 characters)"]</ul> </div> </div>
I’m really new to rails programming, but I really can’t get.
Thanks, Marcello
Your
ifstatement should start with a-, not a=:And your loop should too:
Generally, if you’re trying to convert from erb to haml,
<% ... %>becomes- ...and<%= ... %>becomes= ...