Best practice for loading aws s3 library on startup


#1

Currently I have followed these instructions to get aws s3 working in
my rails app

http://developer.amazonwebservices.com/connect/entry.jspa?entryID=608

But its a little messy as a lot of the file uploading is actually done
in the controller when I think it should be done in the model.
Currently its done like this

class PhotoController < ApplicationController
before_filter :login_required
layout ‘scaffold’

#load model
model :s3_model

#create S3::AWS handle
S3Model.init(@config_file)

The current files to load in the aws are:
/lib/S3.rb (ruby library to connect to aws)
/model/s3_model.rb

What I would like to do is put all of the aws s3 calls in the model
when uploading a photo. I’m thinking instead to do this…

class ApplicationController < ActionController::Base
include S3
model :s3_model

#create S3::AWS handle
S3Model.init(@config_file)

But if I do this… this would only given accessibility to the aws
handler in the controller and not the model right?

If I had a class ProfilePicture < ActiveRecord::Base how would I give
the aws handler visibility there?

thanks in advance!
-dan