aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2017-07-24 15:24:12 +0200
committerTeddy Wing2017-08-01 19:16:02 +0200
commit0e49a76f4510a1bef43445f4e3621e313bd5ea66 (patch)
tree0ec10810ac4e4cfa88dead6cb3977703e43d6296
parent0603bc1f91ebfc9b2a3992e72598566e4203c2cb (diff)
downloadchouette-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.rb2
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)