Skip to content

Commit

Permalink
Merge pull request #8 from bdurand/ignore-invalid-associations
Browse files Browse the repository at this point in the history
Ignore invalid associations
  • Loading branch information
bdurand authored May 24, 2024
2 parents 557bfd8 + 0578280 commit dc4aa86
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 1.2.1

### Changed

- Ignore invalid associations when inspecting reflections on `sync_all!` to establish the load order. These kinds of errors have nothing to do with the support table definition and create confusion when the are raised while syncing data.

## 1.2.0

### Added
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2.0
1.2.1
3 changes: 3 additions & 0 deletions lib/support_table_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,9 @@ def support_table_dependencies(klass)
next unless reflection.belongs_to? || reflection.through_reflection?

dependencies << reflection.klass
rescue => e
message = "Error inspecting reflection #{reflection.name} on #{klass.name}: #{e.inspect}"
klass.logger&.warn(message)
end

dependencies
Expand Down
3 changes: 3 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ class Color < ActiveRecord::Base
has_many :things
has_many :shades, through: :things

# Intentionally invalid association
belongs_to :non_existent, class_name: "NonExistent"

validates_uniqueness_of :name

def group_name=(value)
Expand Down

0 comments on commit dc4aa86

Please sign in to comment.