acts_as_attachment - 1 form

Hi all, I've asked some seriously detailed questions about this in other
forums and you'd think I'd set some user preference to "set my posts to
invisible". LOL

When it comes right down to it, my question is simple.

Can you use 1 form to save an object and that object's attachment?. All
of the examples I've seen (all 2 of them) show the controller/model/view
for DVD Covers, but not for DVDs. Why would you have two actions for
this? One page to create the DVD and another to create the DVD Cover?
It seems silly to me. I want to create/upload and validate both at the
same time, in the same form. IS THIS POSSIBLE? If so, do you have any
example code? Am I making sense here? Isn't it better to input all of
the information for the DVD and upload the cover on the same page?

Sure. It'd work like creating to of any other models in the same
controller action:

Something like that, though you can get more creative and create the
cover in an after_save callback of the dvd if you want.

def create
  @dvd =[:dvd]
  @dvd_cover =[:dvd_cover])
  Dvd.transaction do!
    @dvd_cover.dvd = @dvd!

I have other issues with this plugin, but I thought I'd start here. (for
instance, I've specified file_system_path => 'public/files' and it is
still looking for the db_files table...)

That's because the key is :path_prefix, not :file_system_path.
:file_system_path still works though, it's a legacy option. Here's
the logic you're looking for:

options[:storage] ||= (options[:file_system_path] ||
options[:path_prefix]) ? :file_system : :db_file

So, you may have to write some tests to see why that's not working.
I've never seen any issues with that though.


Settle down, generate the rdocs from the source, or just read the
source. It's not that big :slight_smile: