diff options
| author | Teddy Wing | 2017-07-24 15:24:12 +0200 |
|---|---|---|
| committer | Teddy Wing | 2017-08-01 19:16:02 +0200 |
| commit | 0e49a76f4510a1bef43445f4e3621e313bd5ea66 (patch) | |
| tree | 0ec10810ac4e4cfa88dead6cb3977703e43d6296 | |
| parent | 0603bc1f91ebfc9b2a3992e72598566e4203c2cb (diff) | |
| download | chouette-core-0e49a76f4510a1bef43445f4e3621e313bd5ea66.tar.bz2 | |
Import: Make `parent` field polymorphic
Have Rails automatically fill in the `parent_id` and `parent_type`
fields by declaring this as a polymorphic field.
The type will always end up being "Import", but this is fine and will
still allow us to use ActiveRecord in an easy way:
https://stackoverflow.com/questions/9628610/why-polymorphic-association-doesnt-work-for-sti-if-type-column-of-the-polymorph#comment47744381_10820800
Refs #3511, #3555
| -rw-r--r-- | app/models/import.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/app/models/import.rb b/app/models/import.rb index c932ecdd9..da8244810 100644 --- a/app/models/import.rb +++ b/app/models/import.rb @@ -3,7 +3,7 @@ class Import < ActiveRecord::Base belongs_to :workbench belongs_to :referential - belongs_to :parent, class_name: to_s + belongs_to :parent, polymorphic: true extend Enumerize enumerize :status, in: %i(new pending successful failed running aborted canceled) |
