Hi,
I have two models:
AdvertisementImages (table: advertisement_images) Advertisement (table: advertisements)
The table advertisement_images has a foreign key to advertisements called advertisement_id. Both tables has one entry where the entry in dvertisement_images belongs to advertisement.
The model code looks lik this so far:
class AdvertisementImages < ActiveRecord::Base file_column :image belongs_to :advertisement end
class Advertisement < ActiveRecord::Base has_many :advertisementimage validates_presence_of :title, :body end
Well... I want now have access to the advertisement images where ever I display an advertisement.
for example:
I have a view where I can edit an advertisment. In this view I wanna display the images as well.. My problem is, that the advertisement doesn't fetch the images automatically.
When I dump the advertisement via <%= debug @advertisement %>, my output is :
--- &id001 !ruby/object:Advertisement attributes: valid_to: "2007-10-06" body: some text title: Villa Katherina service: id: "1" valid_from: "2007-10-06" active: "0" parent: errors: !ruby/object:ActiveRecord::Errors base: *id001 errors: {}
I must have done a mistake somewhere in my declarations or so.... does anyone know what I've done wrong ??
Thanx in advance,
alex !