There are a lot of JQuery plugins that provide functionality of ajax file upload. In case when we don't need to visualize upload progress but simple need just a possibility to perform ajax file upload I usually use remotipart gem https://github.com/JangoSteve/remotipart
Step 1.
Append following gems in our Gemfile:
Step 2.
Include JQuery, JQuery UI and remotipart in your application.js
Step 3.
Add remote parameter to your form
Here is my simple CRUD rails application that implements user creation with avatar uploading.
Link to github page https://github.com/serghei-topor/ajax-file-upload-example-rails
Installation:Step 1.
Append following gems in our Gemfile:
gem 'jquery' gem 'jquery-ui-rails' gem 'remotipart', '~> 1.2'
Step 2.
Include JQuery, JQuery UI and remotipart in your application.js
//= require jquery //= require jquery.ui.all //= require remotipart
Step 3.
Add remote parameter to your form
= form_for user, authenticity_token: true, :multipart => true, data: {remote: true} do |f|
Here is my simple CRUD rails application that implements user creation with avatar uploading.
Link to github page https://github.com/serghei-topor/ajax-file-upload-example-rails
Step 1: Install system dependencies (Imagemagick and PostgreSQL)
sudo apt-get install -y imagemagick libmagickwand-dev rsvg-convert exiv2 libpq-dev
Step 2: Clone project from github
git clone https://github.com/serghei-topor/ajax-file-upload-example-rails.git
Step 3: Run migrations
rake db:migrate
No comments:
Post a Comment