Module: Transloadit::Rails::ViewHelper
- Defined in:
- lib/transloadit/rails/view_helper.rb
Instance Method Summary collapse
-
#transloadit(template, options = {}) ⇒ Object
Inserts hidden fields specifying and signing the template for Transloadit to process.
-
#transloadit_jquerify(id, options = {}) ⇒ Object
Enables the jQuery integration for Transloadit, and ensures the form is marked with an encoding type of ‘multipart/form-data`.
Instance Method Details
#transloadit(template, options = {}) ⇒ Object
Inserts hidden fields specifying and signing the template for Transloadit to process.
template - The String or Symbol template name. options - The Hash options used to refine the Assembly (default: {}):
:steps - The Hash with Assembly Steps (optional).
:max_size - The Integer maximum size an upload can have in bytes (optional).
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/transloadit/rails/view_helper.rb', line 12 def transloadit(template, = {}) params = Transloadit::Rails::Engine.template(template, ).to_json fields = hidden_field_tag(:params, params, :id => nil) if Transloadit::Rails::Engine.configuration['auth']['secret'].present? signature = Transloadit::Rails::Engine.sign(params) fields << hidden_field_tag(:signature, signature, :id => nil) end fields end |
#transloadit_jquerify(id, options = {}) ⇒ Object
Enables the jQuery integration for Transloadit, and ensures the form is marked with an encoding type of ‘multipart/form-data`.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/transloadit/rails/view_helper.rb', line 28 def transloadit_jquerify(id, = {}) version = Transloadit::Rails::Engine.configuration['jquery_sdk_version'] || 'v2-latest' javascript_tag %{ jQuery(function($) { var script = '//assets.transloadit.com/js/jquery.transloadit2-#{version}.js'; $.getScript(script, function() { $('##{id}') .attr('enctype', 'multipart/form-data') .transloadit(#{()}); }); }); } end |