Ruby on Rails Monday, November 14, 2016

If I understand you correclty you want to do something like:

<% fields.each do |field| %>
  <%= f.label field %>
  <%= f.text_field field, class: 'form-control' %>
<% end %>

where fields is an array of symbols representing the names of attributes you want to accept via the form.

Personally, I prefer to have things spelled out explicitly as it's easier to see the final shape of HTML. If your goal is to save typing maybe you could consider using some kind of snippets?

Cheers
Greg

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAA6WWt_zq9K%2BdBqDo25%3Dpthvp%3D1aH-ZrfDOYP%2BybA9c05mGsEg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment