Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ PATH
specs:
attachinary (1.2.6)
cloudinary (~> 1.0.41)
coffee-rails
rails (~> 3.2)

GEM
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
53 changes: 26 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions attachinary.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down