search for: add_with_save_names

Displaying 1 result from an estimated 1 matches for "add_with_save_names".

2012 Sep 25
3
Proposal for a new ActiveModel::Errors structure
...alidations actually failed for a given field, as AM::Errors provides only field name and translated error message. We''ve got a simple workaround for this issue: module ActiveModel class Errors def error_types @_error_types ||= Hash.new{|hash,k| hash[k] = []} end def add_with_save_names(attribute, message = nil, options = {}) message ||= :invalid message = message.call if message.is_a?(Proc) error_types[attribute] << message add_without_save_names(attribute, message, options) end alias_method_chain :add, :save_names end end This solution...