Sha256: df14de97af05394731e0d38a2c7f94667697c728f02bea6f67b39bd285a321d9
Contents?: true
Size: 1.4 KB
Versions: 1
Compression:
Stored size: 1.4 KB
Contents
if Rails.env == 'development' ActionView::Helpers::FormHelper.class_eval do def form_for_with_development_errors(*args, &block) form_for_without_development_errors(*args) do |form| html = ''.html_safe if form.object && form.object.respond_to?(:errors) && form.object.errors.any? html << content_tag(:div, form.object.errors.full_messages.collect { |m| h m }.join('<br />').html_safe, :class => 'development_errors', :onclick => 'this.parentNode.removeChild(this);') html << '<style type="text/css"><!--'.html_safe css = <<-EOF .development_errors { position: fixed; bottom: 0; right: 0; z-index: 999999; font-size: 11px; line-height: 15px; background-color: #fed; border-top: 1px solid #cba; border-left: 1px solid #cba; color: #821; padding: 10px; cursor: pointer; filter:alpha(opacity=80); -moz-opacity:0.8; -khtml-opacity: 0.8; opacity: 0.8; } EOF html << css.html_safe html << '</style>'.html_safe end html << capture(form, &block) Rails.version.to_i < 3 ? concat(html) : html end end alias_method_chain :form_for, :development_errors end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
katapult-0.1.2 | lib/generators/katapult/basics/templates/config/initializers/form_for_with_development_errors.rb |