Deprecated

Rails SDK Rails SDK

This SDK has been deprecated. Use the Ruby SDK or Uppy instead.

Install

$ gem install transloadit-rails

or add the transloadit-rails Gem to your Rails project's Gemfile and update your bundle.

$ echo "gem 'transloadit-rails'" >> Gemfile
$ bundle install

After installation you need to run the transloadit:install generator to complete the setup.

$ rails g transloadit:install

Usage

Refer to the Templates (which you have set in the config) with the transloadit helper.

<%= form_for :upload, :html => { :id => 'upload' } do |form| %>
  <%= transloadit :s3_store %>
  <%= form.label      :file, 'File to upload' %>
  <%= form.file_field :file %>
  <%= form.submit %>
<% end %>

<%= javascript_include_tag '//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js' %>
<%= transloadit_jquerify :upload %>

This requires jQuery, and loads the Transloadit jQuery plugin. Be sure to exclude the <%= javascript_include_tag '//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js' %> tag if you already have jQuery loaded.

JavaScript also ensures your form is encoded as multipart/form-data.

If you want to use the automatic transloadit parameter decoding, you have to include the Transloadit::Rails::ParamsDecoder module into your controller

class YourController
  include Transloadit::Rails::ParamsDecoder
end

That way the param[:transloadit] is automatically decoded for you, if it exists.

Note: Since it's still very young, the Transloadit Rails SDK does not include batteries for it yet, but if you're looking for a jQuery-less integration, check out Uppy, our next-gen file uploader for the web.

Example

An example rails application following the tutorial above can be found in the examples directory.

Documentation

See GitHub for the full documentation.

Related blog posts