Skip to content

Instantly share code, notes, and snippets.

@salami-art
Created April 12, 2019 13:14
Show Gist options
  • Save salami-art/95f208eb602629cc3b2112f940ed3ebd to your computer and use it in GitHub Desktop.
Save salami-art/95f208eb602629cc3b2112f940ed3ebd to your computer and use it in GitHub Desktop.
class Rating::Option < ApplicationRecord
belongs_to :rating_type, class_name: 'Rating::Type', :foreign_key => "rating_type_id"
has_many :rating_scores, class_name: 'Rating::Score', :foreign_key => "rating_option_id", dependent: :destroy
end
class Rating::Score < ApplicationRecord
belongs_to :rating_type, class_name: 'Rating::Type', :foreign_key => "rating_type_id"
belongs_to :rating_option, class_name: 'Rating::Option', :foreign_key => "rating_option_id"
end
class Rating::Type < ApplicationRecord
has_many :rating_options, class_name: 'Rating::Option', :foreign_key => "rating_type_id", dependent: :destroy
has_many :rating_scores, class_name: 'Rating::Score', :foreign_key => "rating_type_id", dependent: :destroy
accepts_nested_attributes_for :rating_options, allow_destroy: true
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment