Exception: Shoulda::Matchers::ActiveRecord::ValidateUniquenessOfMatcher::ExistingRecordInvalid

Inherits:
Error
  • Object
show all
Includes:
Shoulda::Matchers::ActiveModel::Helpers
Defined in:
lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Shoulda::Matchers::ActiveModel::Helpers

#default_error_message, #format_validation_errors, #pretty_error_messages

Methods inherited from Error

create, #initialize, #inspect

Constructor Details

This class inherits a constructor from Shoulda::Matchers::Error

Instance Attribute Details

#underlying_exceptionObject

Returns the value of attribute underlying_exception.



1140
1141
1142
# File 'lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb', line 1140

def underlying_exception
  @underlying_exception
end

Instance Method Details

#messageObject



1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
# File 'lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb', line 1142

def message
  <<-MESSAGE.strip
validate_uniqueness_of works by matching a new record against an
existing record. If there is no existing record, it will create one
using the record you provide.

While doing this, the following error was raised:

#{Shoulda::Matchers::Util.indent(underlying_exception.message, 2)}

The best way to fix this is to provide the matcher with a record where
any required attributes are filled in with valid values beforehand.
  MESSAGE
end