granite
granite copied to clipboard
through in has_many doesn't work
Hi
I try to do a has_many through relationship, like this:
class User < Granite::Base
....
has_many albums : Album
has_many :photos, class_name: Photo, through: :albums
end
and the album has:
class Album < Granite::Base
...
belongs_to user : User, foreign_key: user_id : Int32?
has_many photo : Photo
end
and photo:
class Photo < Granite::Base
...
belongs_to album : Album, foreign_key: album_id : Int32?
end
But when I do this:
user.photos
I get nothing, user.albums gives me a list of the albums, and Photo.first give me the first photo, with correct album_id.