So I am trying to make a content system in phoenix, where there are courses, folders, and lessons, and object is the backbone of everything, so:
Object:
has_many :children, Content.Object
belongs_to :parent, Content.Object
Course
belongs_to :object, Content.Object
Folder
belongs_to :object, Content.Object
This method has a problem, though. I can't seem to find a way to get the folder from a course. I want to be able to do something like this:
iex(1)> course = Content.get_course!(1)
iex(2)> [folderObj | _] = course.object.children
iex(3)> folder = folderObj.item
But obviously the item field doesn't exist on object. How would I add this? (Also I can add more code if it isn't clear, just comment)