Been loving your posts, Dan. Please keep them up!
Cyrus Eslami
1

Thanks Cyrus! We do have entities with relations across engine boundaries. Sometimes we’ll declare the associations in the models anyway, but usually we won’t. For example, let’s say we have an engine that contains our Trip model which depends on another engine that contains our User model. Ideally, Trip should know about User but User shouldn’t know about Trip. However, I don’t find it too egregious to put belongs_to :trip in the User class. The association wouldn’t work from inside the User engine (you’d get a NameError uninitialized constant Trip), but it would allow the Trip engine to call user.trips. Most of the time though, we’ll find trips for a user by doing Trip.where(:user_id => user.id). It’s a little more verbose than user.trips, but it’s not too bad to call it that way, and then it keeps all references to trip out of User.