UNDER DEVELOPMENT

What does it do?

Part of the 'buddies' gem that aims to bring some common social features to a rails site. Buddies avatar gem provides user avatar and cropping feature. Image cropping technique is credited to railscasts.com

Setup to use rackspace

  • Add fog gem
  • Overwrite user

user.rb

class User ...

  # For crop only, avatar_geometry opens it
  def avatar_rackspace_path
    "http://#{RACKSPACE_CONFIG[:uploads_url]}/" + avatar.current_path
  end

  def avatar_upload_path
    if Rails.env.test? or Rails.env.cucumber?
      super
    else
      avatar_rackspace_path
    end
  end

end
  • Setup carrierwave initializer

Load rackspace.yml

RACKSPACE_CONFIG = YAML.load(File.read("#{Rails.root}/config/rackspace.yml"))[Rails.env].symbolize_keys

config/initializers/carrierwave.rb

CarrierWave.configure do |config|
  config.fog_credentials = {
    :provider           => 'Rackspace',
    :rackspace_username => RACKSPACE_CONFIG[:username],
    :rackspace_api_key  => RACKSPACE_CONFIG[:api_key]
  }
  config.fog_directory = RACKSPACE_CONFIG[:uploads_dir]
  config.fog_host = "http://#{RACKSPACE_CONFIG[:uploads_url]}"
end

avatar_uploader

storage :fog unless Rails.env.test? or Rails.env.cucumber?

This project rocks and uses MIT-LICENSE.