Skip to content

Instantly share code, notes, and snippets.

@olvap
Last active May 9, 2018 15:28
Show Gist options
  • Save olvap/f98c225dcc3bf13f0813a27828846965 to your computer and use it in GitHub Desktop.
Save olvap/f98c225dcc3bf13f0813a27828846965 to your computer and use it in GitHub Desktop.
### using 1 model for modules
class CercaModule
has_many: sugestions
has_many: lessons
# attributes: lesson_module_type # "collection_module" || "lesson_module"
end
class Sugestion
belongs_to :lesson
belongs_to :cerca_module
end
### using two models for modules
class CercaModule
has_many: sugestions
has_many: lessons
end
class Sugestion
belongs_to :lesson
belongs_to :lesson_module # this can be change to only use lesson_modules types
end
class LessonModule < CercaModule
end
class CollectionModule < CercaModule
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment