Skip to main content

Advanced Polymorphic: Many-to-Many

Premium
2:40

The Full Lesson is Only for Premium Members

Want to access all of our courses? (30 h 33 min)

You also get:

55 courses
Premium tutorials
Access to repositories
Private Discord
Get Premium for $129/year or $29/month

Already a member? Login here

Comments & Discussion

RJ
Ravindrasinh Jadav ✓ Link copied!

Shouldn't the pivot table have model_id and model_type instead of just photo_id ?

PK
Povilas Korop ✓ Link copied!

It's not photo_id, it's photoable_id

A
amauro ✓ Link copied!

shouldn't there be a unique constraint or index for all three fields (photo_id, photoable_it and photoable_type) to avoid multiple assignements of one photo to a user?

PK
Povilas Korop ✓ Link copied!

Good idea, that would be a good extra constraint.

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.