I have a problem related to Single Table Inheritance, and I have never used it, can you guys help me?
Deck model
name: string
has_many Content
Content has 2 types: Content::ForTerm / Content::ForPhrase
Content::ForTerm has many Term
Content::ForPhrase has many Phrase
term model :
id, word, meaning, reading
phrase model :
id, sentence
Create a model class with class name as Content and two other child class as Term and Phrase which must be inherited from class Content
# app/models/Content.rb
class Content < ApplicationRecord
#your code
end
# app/models/term.rb
class Term < Content
#your code
end
# app/models/phrase.rb
class Phrase < Content
#your code
end
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.