Forum: Ruby on Rails best practice for loading aws s3 library on startup

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
dan kuwachi (Guest)
on 2007-03-19 19:36
(Received via mailing list)
Currently I have followed these instructions to get aws s3 working in
my rails app

http://developer.amazonwebservices.com/connect/ent...

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
This topic is locked and can not be replied to.