Skip to content

Instantly share code, notes, and snippets.

@jgaskins
Created March 27, 2012 01:08
Show Gist options
  • Save jgaskins/2211381 to your computer and use it in GitHub Desktop.
Save jgaskins/2211381 to your computer and use it in GitHub Desktop.
Idea for Rails form helpers
<%= form_for @article do |f| %>
<div class="field">
<%= f.label :title %>
<%= f.text_field :title %>
</div>
<div class="field">
<%= f.label :body %>
<%= f.text_area :body %>
</div>
<% end %>
<%= form_for @article do |f| %>
<%= f.field :title %>
<%= f.field :body %>
<% end %>
@rafaelfranca
Copy link

This is how SimpleForm works now.

@jgaskins
Copy link
Author

This was just an example. I've used SimpleForm; it's an awesome gem and it inspired this entire line of thinking for me. There are several view helpers in Rails where we may be able to remove the "one HTML tag per helper method" abstraction, not necessarily just in forms (I mentioned form helpers because that's what @solnic was referring to).

I like that we can have that level of granularity because there are always going to be times it will be helpful or even necessary, but when you're writing the same boilerplate markup in so many different views, it becomes cumbersome. When you end up loading the same gems and including the same helpers in every app you write, then the loading of those gems and inclusion of those helpers becomes boilerplate, as well — at least in my mind. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment