Skip to content

Instantly share code, notes, and snippets.

@msroot
Created October 9, 2012 20:54
Show Gist options
  • Save msroot/3861361 to your computer and use it in GitHub Desktop.
Save msroot/3861361 to your computer and use it in GitHub Desktop.
rails errors
<% if @entry.errors.include?(:state) %>
<div class="control-group">
<div class="controls">
<div class="error"> <%= @entry.errors["state"][0] %></div>
</div>
</div>
<% end %>
###############OR
#in application rb
Include the errors in the html fields
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
"<div class=\"field_with_errors\">
#{html_tag}
<div class=\"error\">#{instance.error_message.first}</div>
</div>".html_safe
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment