Naming a Join Model

I’m looking for advice on naming a join model. Naming Things Is Hard!

I have a Lesson model and an Upload model. Previously an Upload was associated with one Lesson:

# upload.rb
  belongs_to :lesson
# lesson.rb
  has_many :uploads

Now we need a many-to-many relationship between them so that an upload can be associated with many lessons and a lesson can still have many uploads. I need a join model so I can record extra values like who added the upload to the lesson, etc.

The best naming I’ve got so far is LessonUpload since so many of the alternatives are either reserved words or are too generic and may become problematic in the future.

I’d prefer a single-word model like Attachment but that’s reserved by Paperclip.

Anyone got any bright ideas for the name?

Typically when modelling, you’re using verbs as association descriptions, and nouns as the models (this is obviously not a hard and fast rule).

Upload is a verb, lesson is more like a noun. The upload should be called a ?resource? and the upload is the association name.

That being said, try not get so caught up in naming conventions, you have now learned something for your next project :slight_smile:

I think I like Resource more than Upload as Christos said.

Perhaps you might also find this article helpful? I certainly did! :slight_smile:

What are these uploads used for? Are they printable activities to use in the classroom or are they coursework submissions ?

If it’s the former then back when I was an English teacher we’d often create lesson plans which required multiple games / props for the class but whenever we talked about them in the context of planning an upcoming lesson we’d describe them as the lesson’s materials or resources.

For printouts (another type of upload?) which we gave to students to complete and hand in (homework etc) we’d often call them the lesson’s assignments.

If I were modelling my former job then I’d probably use materials resources and/or assignments as the joins name. As a teacher they express an attachment to a lesson whereas an upload by itself does not.

Hope that helps.

@christoshrousis @sarah-i-nbr Although it seems like a good name, I’m not keen on using Resource. Partly because it feels a little too generic and partly because that word is used quite regularly throughout the app to refer to (ironically) a generic item, for example in the Devise framework and CanCan.

We actually need to move away from Upload as the model name now because new requirements mean that not all of these items will have been uploaded by the user, some may just be links pointing to external resources (YouTube video, Spotify song etc).

And still looking for a good association name too. Again, Upload won’t cut it here either because of the above.

@robodisco Thanks for your input. The items attached to lesson are reference materials like a video of a guitar performance, a piece of sheet music or a link to a Spotify song.

They aren’t items that are meant to be completed by the student, so Assignment seems a little off-target.

Seems I’m in a murky naming space where the names are either reserved words or too generic.

I’ll post back when I finally decide which way to go.