Exception: PaperTrailAssociationTracking::Reifiers::HasOne::FoundMoreThanOne Private
- Inherits:
-
RuntimeError
- Object
- RuntimeError
- PaperTrailAssociationTracking::Reifiers::HasOne::FoundMoreThanOne
- Defined in:
- lib/paper_trail_association_tracking/reifiers/has_one.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
A more helpful error message, instead of the AssociationTypeMismatch you would get if, eg. we were to try to assign a Bicycle to the :car association (before, if there were multiple records we would just take the first and hope for the best).
Constant Summary collapse
- MESSAGE_FMT =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
<<~STR Unable to reify has_one association. Expected to find one %s, but found %d. This is a known issue, and a good example of why association tracking is an experimental feature that should not be used in production. That said, this is a rare error. In spec/models/person_spec.rb we reproduce it by having two STI models with the same foreign_key (Car and Bicycle are both Vehicles and the FK for both is owner_id) If you'd like to help fix this error, please read https://github.com/airblade/paper_trail/issues/594 and see spec/models/person_spec.rb STR
Instance Method Summary collapse
-
#initialize(base_class_name, num_records_found) ⇒ FoundMoreThanOne
constructor
private
A new instance of FoundMoreThanOne.
- #message ⇒ Object private
Constructor Details
#initialize(base_class_name, num_records_found) ⇒ FoundMoreThanOne
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of FoundMoreThanOne.
30 31 32 33 |
# File 'lib/paper_trail_association_tracking/reifiers/has_one.rb', line 30 def initialize(base_class_name, num_records_found) @base_class_name = base_class_name.to_s @num_records_found = num_records_found.to_i end |
Instance Method Details
#message ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
35 36 37 |
# File 'lib/paper_trail_association_tracking/reifiers/has_one.rb', line 35 def format(MESSAGE_FMT, @base_class_name, @num_records_found) end |