OuvragesFileUploader
Rails Engine to use jQuery File Upload with Paperclip
Installation
Add this line to your application's Gemfile:
gem 'ouvrages_file_uploader'
And then execute:
$ bundle
Or install it yourself as:
$ gem install ouvrages_file_uploader
You must already have jquery installed.
Then add this to your application.js:
//= require uploaded_files
And this to your application.css:
*= require uploaded_files
You need to copy migrations to your project:
$ rake ouvrages_file_uploader_engine:install:migrations
And then run:
$ rake db:migrate
Usage
Let's consider, we have a resource Post.
You need to generate a migration for add an attachment:
$ rails generate migration add_image_to_posts image:attachment
$ rake db:migrate
And call in your model accepts_uploaded_file_for(attribute)
:
class Post < ActiveRecord::Base
attr_accessible :image
has_attached_file :image
:image
accepts_uploaded_file_for :image
end
Then in your view app/views/posts/_form.html.erb
:
<%= file_upload(form, :image) %>
For extra information on how to deal with Paperclip, please refer offical documentation.
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request