/ Published in: Ruby

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
# config/environment.rb require "#{RAILS_ROOT}/app/overrides/all" # app/overrides/all.rb Dir[ File.dirname( __FILE__ ) + "/**/*.rb" ].each { |file| require( file ) } # app/overrides/active_record.rb module ActiveRecord class Errors # ONLY RETURN THE 1ST ERROR FOR EACH ATTRIBUTE def first_messages list = [] first_messages = [] @errors.each_key do |attr| @errors[ attr ].each do |msg| next if msg.nil? if attr == 'base' unless list.include? attr first_messages << msg list << attr end else unless list.include? attr first_messages << @base.class.human_attribute_name( attr ) + ' ' + msg list << attr end end end end return first_messages end end end
Comments
