开发者

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] }) 开发者_Python百科%>
</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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜