I just want to know something : For the example, let's assume a picture gallery with two table, gallery and picture, gallery has_many pictures, picture belongs_to gallery. Picture can be set in gallery cover with a field 'cover', null or true, right ?
So if i want select all my galleries, and the cover image if the gallery have one, i naturally do :
Aaand... no. The galleries who don't own a cover picture aren't selected at all. I checked the query and logically, there is a where at the end who exclude them.
I just want to not select relating picture if there is no cover in gallery but select the gallery in each case.
So i have a way to do it or it's not possible with the ORM ?
I would do that with two relations: - gallery has_many pictures - gallery has_one coverpicture
both pointing to the same Model_Picture, and add a picture_id to gallery as FK for the cover picture.
Assuming your controller logic makes sure a cover picture can only be selected from the pictures in the gallery, both can share the same belongs_to the other way (picture->gallery).