Forum: Ruby on Rails Optimize redundant code

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
263762338cb0208f3412d61dcf334fa6?d=identicon&s=25 atmorell (Guest)
on 2009-02-10 12:09
(Received via mailing list)
Hello,

I would like to wrap the class type-text around each label/text_field.
There must be a better way than my example below? I don't know how to
do this without an object to loob through :)

<% content_tag :div, :class => "type-text" do -%>
  <%= label(:user, :login, "Username") %><%= f.text_field :login %>
<% end %>

<% content_tag :div, :class => "type-text" do -%>
  <%= label(:user, :firstname, "Firstname") %><%=
f.text_field :firstname %>
<% end %>

<% content_tag :div, :class => "type-text" do -%>
  <%= label(:user, :lastname, "Lastname") %><%= f.text_field :lastname
%>
<% end %>

Best regards.
Asbjørn Morell.
A91bd6cef23eb3516245a092e196c4da?d=identicon&s=25 Maurício Linhares (mauricio)
on 2009-02-10 13:22
(Received via mailing list)
What you need is a custom form buider ->
http://onrails.org/articles/2008/06/13/advanced-ra...

-
Maurício Linhares
http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/
(en)
This topic is locked and can not be replied to.