I have 开发者_如何学JAVAan existing entry
scaffold. I'd like to add image upload to my existing model/controller/view without too much hassle--and I'd like to add some ajax after I get it working.
That said, I'm pretty new to rails.
- I s there a simple, ajax-compatable gem to help?
- How do I implement it? (Step-by-step, because I'm pretty slow to learn)
Ruby on Rails AJAX file upload
http://khamsouk.souvanlasy.com/articles/ajax-file-uploads-in-rails-using-attachment_fu-and-responds_to_parent
Look for Step 6. Using iframes and responds_to_parent in the article. Note that it uses attachment_fu for handling file uploads. But the idea is same for both paperclip & carrierwave
Here's a good demo of how to upload images with Rails 3. It uses Uploadify with the Dragonfly gem.
https://github.com/rdetert/FormFly
Same post AJAX upload using Prototype.js plugin
https://github.com/JangoSteve/remotipart
Remotipart is a Ruby on Rails gem enabling AJAX file uploads with jQuery in Rails 3.0 and Rails 3.1 remote forms. This gem augments the native Rails jQuery remote form functionality enabling asynchronous file uploads with little to no modification to your application.
gem 'remotipart', '~> 1.0'
bundle install
精彩评论