A] Cloudinary:

Cloudinary is a cloud service that offers a solution to a web application's entire image management pipeline. It is used to easily upload images to the cloud.
It automatically performs smart image resizing, cropping and conversion without installing any complex software.
Also, integration of Facebook or Twitter profile image extraction in a snap,that too in any dimension and style to match your website’s graphics requirements.

  1. Add following line to your Gemfile:
    gem 'cloudinary'

  2. Add following line to config/cloudinary.yml

  api_key:    //enter api key
  api_secret: //enter api secret
  cloud_name: //enter cloud name
  enhance_image_tag:    true
  static_image_support: false

B] Attachinary:

When developing a website you are required for a somewhat tedious work of handling dynamically uploaded content. The constantly added content includes images uploaded by your users and other files.
Attachinary does an amazing job in simplifying attachment management in your application's model. Attachinary uses Cloudinary service to upload images.

  1. Add following line to your Gemfile:
    gem 'attachinary'

  2. Add following line to your application.rb file:

  require "attachinary/orm/active_record
  1. Run the following rake tasks:
rake attachinary:install:migrations
rake db:migrate
  1. Next, add following line in your routes.rb file:
  mount Attachinary::Engine => "/attachinary"
  1. Add folowing line in head section of your application layout file:
  = cloudinary_js_config
  1. Finally, you have to include necessary javascript files. This is to enable attaching files from UI ( for eg. images ). In your application.js, add following lines:
//= require jquery.ui.widget
//= require jquery.iframe-transport
//= require jquery.fileupload
//= require cloudinary/jquery.cloudinary
//= require attachinary


Consider an example wherein we have a bottle that can have multiple images.

In this case,

  1. In the bottle model, we have:
class Bottle < ActiveRecord::Base
  attr_accessible :name, :description, :sku
  has_attachments :photos, maximum: 3

  has_many :attachinary_files, as: :attachinariable,
            foreign_key: :attachinariable_id, primary_key: :sku,
            conditions: { scope: 'images' }
  1. Upload images to clodinary:
= simple_form_for bottle, url: '/admin/attach_images', method: :put do |f|
    = f.input :id, as: :hidden
    = f.label 'Please select Images for Bottle: '
    = f.input :images, as: :attachinary, label: false
    = f.submit 'Attach Image', disable_with: "Attaching Images..."
  1. In the controller add the code:
  images.each do |image|
      .except('signature', 'created_at', 'bytes', 'type',
      'etag', 'url', 'secure_url'))
  1. To display the image from cloudinary, use the following in your view file:
   bottle = Bottle.find(params[:id])
   photo = bottle.attachinary_files.where(is_primary: true)
   = cl_image_tag(photo.path, :size => '70x50', :crop => :fill, :radius => 20)

Useful links:-
Cloudinary Gem(Cloudinary Gem)
Attachinary Gem(Attachinary Gem)
Attachinary - a modern attachments solution for Ruby on Rails(Attachinary Blog)