Skip to content

Instantly share code, notes, and snippets.

@rubyrider
Last active November 10, 2016 21:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rubyrider/6f80787ffaa0d033c94e to your computer and use it in GitHub Desktop.
Save rubyrider/6f80787ffaa0d033c94e to your computer and use it in GitHub Desktop.
module ActiveModel
class Errors
attr_accessor :error_code, :developer_message, :more_info
def add(attribute, message = :invalid, options = {})
options.each { |k,v| instance_variable_set("@#{k}", v) }
message = normalize_message(attribute, message, options)
if exception = options[:strict]
exception = ActiveModel::StrictValidationFailed if exception == true
raise exception, full_message(attribute, message)
end
self[attribute] << message
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment