diff --git a/Gemfile.lock b/Gemfile.lock index 36c721f6..5f932b78 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -3,6 +3,7 @@ PATH specs: attachinary (1.2.6) cloudinary (~> 1.0.41) + coffee-rails rails (~> 3.2) GEM @@ -36,7 +37,7 @@ GEM i18n (= 0.6.1) multi_json (~> 1.0) addressable (2.3.4) - arel (3.0.2) + arel (3.0.3) aws_cf_signer (0.1.1) builder (3.0.4) capybara (2.1.0) @@ -172,7 +173,7 @@ GEM sqlite3 (1.3.7) thor (0.18.1) tilt (1.4.1) - treetop (1.4.12) + treetop (1.4.15) polyglot polyglot (>= 0.3.1) tzinfo (0.3.37) diff --git a/README.md b/README.md index 7cb13cbd..91fa2484 100644 --- a/README.md +++ b/README.md @@ -26,30 +26,51 @@ Attachinary uses [Cloudinary](http://cloudinary.com) service. Gem is structured First, make sure that you have [cloudinary gem](https://github.com/cloudinary/cloudinary_gem) installed and properly configured. -Add following line to your `Gemfile`: +Add the following line to your `Gemfile`: gem 'attachinary' -Specify which ORM you wish to use by adding following line to your `application.rb` file (or custom initializer): +Specify which ORM you wish to use by adding the following line to your `application.rb` file (or custom initializer): require "attachinary/orm/YOUR_ORM" # active_record or mongoid -If you're using `ActiveRecord` ORM, then run following lines to generate required table: +If you're using `ActiveRecord` ORM, then run the following commands to generate the required table: rake attachinary:install:migrations rake db:migrate -Next, add following line in your `routes.rb` file: +Next, add the following line in your `routes.rb` file: mount Attachinary::Engine => "/attachinary" It will generate '/attachinary/cors' which will be used for iframe file transfers (for unsupported browsers). -Finally, make sure that you have following line in head section of your application layout file: +Then, make sure that you have the following line in the head section of your application layout file. This must +come **after** your 'javascript_include tag :application' directive. <%= cloudinary_js_config %> +Now, you have to include the necessary javascript files. In your `application.js`, add the following: +```javascript +//= require jquery.ui.widget +//= require jquery.iframe-transport +//= require jquery.fileupload +//= require cloudinary/jquery.cloudinary +//= require attachinary +``` + +If you don't have the jQuery File Upload files, you can use this rake task to fetch (or update) them: + +``` +rake attachinary:fetch_fileupload +``` + +And finally, add this code on document ready: + +```javascript +$('.attachinary-input').attachinary() +``` ## Usage @@ -80,28 +101,6 @@ If you're using [SimpleForm](https://github.com/plataformatec/simple_form), you <%= f.input :photos, as: :attachinary %> ``` -Finally, you have to include necessary javascript files. In your `application.js`, add following lines: - -```javascript -//= require jquery.ui.widget -//= require jquery.iframe-transport -//= require jquery.fileupload -//= require cloudinary/jquery.cloudinary -//= require attachinary -``` - -If you don't have the jQuery File Upload files, you can use following rake task to fetch (or update) them: - -``` -rake attachinary:fetch_fileupload -``` - -And, add this code on document ready: - -```javascript -$('.attachinary-input').attachinary() -``` - Attachinary jquery plugin is based upon [jQuery File Upload plugin](https://github.com/blueimp/jQuery-File-Upload) but without any fancy UI (it leaves it up to you to decorate it). Plugin is fully customizable. It uses John Resig's micro templating in the background, but you can override it with whatever you like. Check out the source code for more configuration options you can set. diff --git a/attachinary.gemspec b/attachinary.gemspec index e57899e9..e62f88f6 100644 --- a/attachinary.gemspec +++ b/attachinary.gemspec @@ -18,6 +18,7 @@ Gem::Specification.new do |s| s.add_dependency 'rails', '~> 3.2' s.add_dependency 'cloudinary', '~> 1.0.41' + s.add_dependency 'coffee-rails' # s.add_dependency "jquery-rails"