I have four models and I am struggling building associations for the last one.
class Color < ActiveRecord::Base has_many :games, through: :game_colors end class GameColor < ActiveRecord::Base belongs_to :game belongs_to :color end class Game < ActiveRecord::Base has_many :game_colors has_many :colors, through: :game_colors has_many :images end class Image < ActiveRecord::Base belongs_to :game #associates with one :color from the :game_colors in :game end
I have the relationship between Color and Game working well through GameColor; I can save/update in a game with no issues. What I am trying to do now is to build an association with one of the colors in the game_colors collection in game to the Image model.
There will be multiple Image instances that will have the same color associated with it. I feel like this is doable from reading through the associations docs but I'm still new to Rails and can't figure out the exact method.
If you suggestions for alternative ways to model this I'd love to hear that as well.