一樣為了專案啊 ... (泣
gem 'plupload-rails'into your Gemfile and execute
bundle installin your
- add following lines into your
//= require moxie
//= require plupload.dev
//= require plupload/i18n/de- for i18n ... maybe it has
//= require plupload.settings- optional, but recommended ...
//= require jquery.plupload.queue- if you want to integrated with jQuery
*= require jquery.plupload.queue
- 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
So, I need to combine
Asset model and
ImageUploader together with
path column, so in my
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
Event ... etc, just feel free to add them, and add
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!
Learn more on https://github.com/gucki/plupload-rails