Skip to content

Instantly share code, notes, and snippets.

@joncode
Last active December 21, 2015 07:49
Show Gist options
  • Save joncode/6274015 to your computer and use it in GitHub Desktop.
Save joncode/6274015 to your computer and use it in GitHub Desktop.
Attachinary how to add ...

Setup


  1. add the cloudinary and attachinary Rails 4 gems

    gem 'cloudinary'

    gem 'attachinary', git: 'git://github.com/rochers/attachinary.git', branch: 'rails4'

    require "attachinary/orm/active_record" in config/application.rb

1b. add the cloudinary.yml file

genarate from cloudinary.com or use from other same account project
	.yml file must have staging section
  1. create the database for the gem

    • rake attachinary:install:migrations
    • rake db:migrate
  2. add attachinary ot the routes fill

    • mount Attachinary::Engine => "/attachinary"
  3. last line of header file Head

    • <%= cloudinary_js_config %>

In App Usage


  1. add to the model where needed

    • has_attachment :photo
  2. add the attachinary file uploader to the view

    • <%= f.attachinary_file_field :photo %>
  3. download the jquery files via rake task

    • rake attachinary:fetch_fileupload
  4. add the javascript files for upload etc

    • //= require jquery.ui.widget
    • //= require jquery.iframe-transport
    • //= require jquery.fileupload
    • //= require cloudinary/jquery.cloudinary
    • //= require attachinary
  5. add this on document ready to javascript

    $('.attachinary-input').attachinary()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment