Skip to content

Instantly share code, notes, and snippets.

@rajib
Created January 3, 2011 11:48
Show Gist options
  • Save rajib/763386 to your computer and use it in GitHub Desktop.
Save rajib/763386 to your computer and use it in GitHub Desktop.
mark_required
<%= mark_required(@user, :email) %>
# module ApplicationHelper
# def mark_required(object, attribute)
# "*" if object.class.validators_on(attribute).map(&:class).include? ActiveModel::Validations::PresenceValidator
# end
# end
1. <%= form_for(@user) do |f| %>
2. <%= render "shared/error_messages", :target => @user %>
3. <div class="field">
4. <%= f.label :name %><%= mark_required(@user, :name) %><br />
5. <%= f.text_field :name %>
6. </div>
7. <div class="field">
8. <%= f.label :email %><%= mark_required(@user, :email) %><br />
9. <%= f.text_field :email %>
10. </div>
11. <div class="actions">
12. <%= f.submit %>
13. </div>
14. <% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment