Module: Uploadcare::Rails::ActionView::Helpers
- Defined in:
- lib/uploadcare/rails/action_view.rb
Class Method Summary collapse
Instance Method Summary collapse
- #uploadcare_include_tag(options = {}) ⇒ Object
- #uploadcare_uploader_field(object_name, method, options = {}) ⇒ Object
- #uploadcare_uploader_options(options) ⇒ Object
- #uploadcare_uploader_tag(name, options = {}) ⇒ Object
Class Method Details
.included(arg) ⇒ Object
37 38 39 |
# File 'lib/uploadcare/rails/action_view.rb', line 37 def self.included(arg) ActionView::Helpers::FormBuilder.send(:include, Uploadcare::Rails::ActionView::FormBuilder) end |
Instance Method Details
#uploadcare_include_tag(options = {}) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/uploadcare/rails/action_view.rb', line 3 def uploadcare_include_tag( = {}) s = Rails.application.config.uploadcare src = '' s..each do |k, v| src << "UPLOADCARE_#{k.to_s.underscore.upcase} = \"#{j(v)}\";\n" end settings_code = javascript_tag(src) version = [:version] || s. min = [:min].nil? || [:min] url = "https://ucarecdn.com/widget/#{version}/uploadcare/uploadcare-#{version}#{'.min' if min}.js" include_code = javascript_include_tag(url) settings_code + include_code end |
#uploadcare_uploader_field(object_name, method, options = {}) ⇒ Object
32 33 34 35 |
# File 'lib/uploadcare/rails/action_view.rb', line 32 def uploadcare_uploader_field(object_name, method, = {}) = () hidden_field(object_name, method, ) end |
#uploadcare_uploader_options(options) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/uploadcare/rails/action_view.rb', line 20 def () .symbolize_keys.deep_merge({ :role => "#{[:role]} uploadcare-uploader", :data => {:path_value => true} }) end |
#uploadcare_uploader_tag(name, options = {}) ⇒ Object
27 28 29 30 |
# File 'lib/uploadcare/rails/action_view.rb', line 27 def uploadcare_uploader_tag(name, = {}) = () hidden_field_tag(name, nil, ) end |