I got a model called Pages that looks like this:
title
description
image_id
background_image
logo
I also got a model calles Images that looks like this:
id
title
What I would like to be able to is to associate these three fields with the image model.
image_id
background_image
logo
image_id works perfectly because of the Page model association:
has_many :images
How do I make it work with background_image and logo?
Hope my question makes any sense. Thanks
UPDATE

In your
Pagemodel, you’ll want to usebelongs_toto specify that it contains a pointer to anImage. For the first one, that’ll just bebelongs_to :image.But you want to have three pointers. You can do that; for each of the other fields, you’ll add an option to
belongs_toto specify that it’s pointing to anImage. You do that using the:class_nameoption, like this;You’ll also probably want to name your columns with
_idat the end, sobackground_image_idandlogo_id– it’s more Railsy that way.All of this is documented in the Rails Guides; the
:class_nameoption is specifically here.