Form scope in partials
Say you have a typical form in Ruby on Rails which begins with:
<% form_for :user do |f| -%>
<label for="user_name">User name</label>
<%= f.text_field :user_name %>
And for some reason you’d like to have a form field separated in a partial. You might wonder (like I did) what to do since you cannot pass the form helper object (f) around. But in the partial you’re also in the form object’s scope, so you can call helper methods simply as:
<%= text_field :user, :email %>