Topic: Using file_column with multiple models

I'm setting up a Rails app with a basic CMS.

I have two models that at times may have associated images - Release and Event. In the CMS, I would like to give the administrator the option to associate one or more images when adding a release or event, in the same form.

My question is how to best set up the database schema and MVC to make this work.

Thanks in advance for any suggestions.

Re: Using file_column with multiple models

For the database schema you'd need the following -

tables:
releases
events
images
releases_images
events_images

releases habtm* images and events habtm images

*has_and_belongs_to_many

I'm not sure what you mean by the MVC you'd need to make this work; Release and Event would be model classes and you just add the image association functionality you need in your controllers/views.

vinnie - rails forum admin

Re: Using file_column with multiple models

What ever you do.  Dont try and Mix the file_column and acts_as_versioned plugins... That is a road to NOWHERE!!!!!

Re: Using file_column with multiple models

Vin, thanks for the help and Alistair I appreciate the tip.

Re: Using file_column with multiple models

actually after the long road to nowhere and the long hard road back.  Ive finially discovered how to do it


class Foo < AR::Base
  acts_as_versioned do
    def self.included(base)
      base.file_column ....
    end
  end
end