title: Rails 4: How to display error message using a prop name in f.label
body: <p>Is it possible to display error message using a prop name in f.label?</p>
  
  <p>I'd like to display "abc is invalid" instead of "Email is invalid", "xyz is too short (minimum is 6 charachtars)" instead of "Password is too short (minimum is 6 charachtars)". </p>
  
  <p>models\user.rb</p>
  
  <pre><code>class User &lt; ActiveRecord::Base
  .
  .
  .
    validates :email, presence: true, format: { with: VALID_EMAIL_REGEX }, uniqueness: { case_sensitive: false }
    validates :password, length: { minimum: 6 }
  .
  .
  .
  end
  </code></pre>
  
  <p>new.html.erb</p>
  
  <pre><code>&lt;div class="row"&gt;
    &lt;div class="form-space"&gt;
    &lt;%= form_for(@user) do |f| %&gt;
      &lt;%= render 'shared/error_messages', object: f.object %&gt;
      &lt;%= render 'fields', f: f %&gt;
      &lt;br&gt;
      &lt;%= f.submit "create", class: "btn btn-warning" %&gt;
    &lt;/div&gt;
    &lt;% end %&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>_fields.html.erb</p>
  
  <pre><code>&lt;%= f.label :email, "abc" %&gt;
  &lt;%= f.text_field :email %&gt;
  
  &lt;%= f.label :password, "xyz" %&gt;
  &lt;%= f.password_field :password %&gt;
  </code></pre>
  
  <p>_error_messages.html.erb</p>
  
  <pre><code>&lt;% if object.errors.any? %&gt;
    &lt;div id="error_explanation"&gt;
      &lt;div class="alert alert-error"&gt;
        The form contains &lt;%= pluralize(object.errors.count, "error") %&gt;.
      &lt;/div&gt;
      &lt;ul&gt;
      &lt;% object.errors.full_messages.each do |msg| %&gt;
        &lt;li&gt;* &lt;%= msg %&gt;&lt;/li&gt;
      &lt;% end %&gt;
      &lt;/ul&gt;
    &lt;/div&gt;
  &lt;% end %&gt;
  </code></pre>