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?

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…)

AAAAAGGGHH,

Shagy

On 3/13/07, Shagymoe [email protected] wrote:

Can you use 1 form to save an object and that object’s attachment?. All

Yes. In addition to the mandatory fields that aaa needs you can define
as many additional fields, validations etc to your model. SO you can
have DVD and DVD attachment in the same form.

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…)

Do you also have :storage => :file_system specified?

On 3/13/07, Shagymoe [email protected] wrote:

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.new(params[:dvd]
@dvd_cover = DvdCover.new(params[:dvd_cover])
Dvd.transaction do
@dvd.save!
@dvd_cover.dvd = @dvd
@dvd_cover.save!
end
end

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.

AAAAAGGGHH,

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


Rick O.
http://lighthouseapp.com
http://weblog.techno-weenie.net
http://mephistoblog.com