Last active
March 25, 2018 19:27
-
-
Save ewilliam/b2f9b84e6f81d8e596bf750e2feaff46 to your computer and use it in GitHub Desktop.
dependent destroy issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Scheme < ApplicationRecord | |
has_one :logo, as: :imageable, class_name: 'Image', dependent: :destroy | |
has_many :steps, class_name: 'Scheme::Step', dependent: :destroy | |
has_many :screens, | |
through: :steps, source: :steppable, source_type: 'Screen' | |
has_many :screen_groups, | |
through: :steps, source: :steppable, source_type: 'Screen::Group' | |
has_many :scheme_responses, class_name: 'Scheme::Response' | |
accepts_nested_attributes_for :screens | |
enum type: { | |
'Survey' => 0, | |
'Story' => 1 | |
} | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Screen < ApplicationRecord | |
has_many :choices, dependent: :destroy | |
accepts_nested_attributes_for :choices, allow_destroy: true | |
enum type: { | |
multiple_choice: 0, | |
multiple_select: 1, | |
text: 2, | |
number: 3, | |
date: 4, | |
read_only: 5, | |
participant_ID: 6 | |
} | |
self.inheritance_column = :_type_disabled | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Scheme::Step < ApplicationRecord | |
belongs_to :scheme | |
belongs_to :steppable, polymorphic: true | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment