简体   繁体   中英

form with errors massage in HAML rails3

I `m change.erb files in.haml. I have such a form:

<% form_for :ticket do |f| %>
<% if @ticket.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@ticket.errors.count, "error") %> prohibited this post from being  saved:</h2>
<ul>
<% @ticket.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>

<p><b>department</b><br/>
<%= select("ticket", "department_id", Department.find(:all).collect{ |d| [ d.name, d.id] }) %>
</p>

<%= submit_tag 'make a request' -%>
<% end %>

The above mentioned works... but for me it`s very complicated task... to convert it to haml very appreciate any help!

You can use a resource such as HTML2Haml which will get you close.

With a little practice, you'll find converting from ERb to Haml, straightforward and fun. The primary conversions are:

  • <% foo ==> - foo
  • <%= foo ==> = foo
  • <foo id="bar" class="baz"> ==> %foo#bar.baz

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM