## plupload-rails with carrierwave -- 實作筆記

1. place gem 'plupload-rails' into your Gemfile and execute bundle install in your Terminal.app
2. add following lines into your application.js and application.css
• 'application.js'
• //= require moxie
• //= require plupload.dev
• //= require plupload/i18n/de - for i18n ... maybe it has zh version :P
• //= require plupload.settings - optional, but recommended ...
• //= require jquery.plupload.queue - if you want to integrated with jQuery
• 'application.css'
• *= require jquery.plupload.queue
3. Place following code on any view files you want.

Okay ... that's it!

### Controller / Model

I want to use the Carrierwave as my uploader, so first of all, I need to install it and make an uploader and I call it ImageUploader with Asset model.

So, I need to combine Asset model and ImageUploader together with path column, so in my asset.rb ...

That's it!

And now, it's Controller's turn.

I have a controller called AssetsController and it has an action called create, that's do some magic in that action:

okay ... that's it. If you want to have an association with User or Event ... etc, just feel free to add them, and add xxx_id in the JavaScript multipart_params settings, for example:

I want those images that I uploaded associated with current_user, I can make multipart_params like that:

See? So easy! Or you can do some magic with your url field, like url: '<%= event_images_path(@event) %>'

Okay ... That's it!