Module: ActsAsAssets::AssetsHelper
- Included in:
- AssetsController
- Defined in:
- app/helpers/acts_as_assets/assets_helper.rb
Instance Method Summary collapse
- #asset_action(model) ⇒ Object
- #asset_file_name(asset) ⇒ Object
- #asset_file_path(asset) ⇒ Object
- #asset_id ⇒ Object
- #asset_label ⇒ Object
- #asset_target ⇒ Object
- #assets_body ⇒ Object
- #destroy_file_path(asset, model) ⇒ Object
- #destroy_link(asset, model) ⇒ Object
- #destroy_method_for(asset) ⇒ Object
- #destroy_path(asset, model, target, type) ⇒ Object
- #name_from(asset) ⇒ Object
- #upload_complete_js_function ⇒ Object
Instance Method Details
#asset_action(model) ⇒ Object
21 22 23 24 |
# File 'app/helpers/acts_as_assets/assets_helper.rb', line 21 def asset_action(model) method_name = "#{model.class.model_name.split('::').first.underscore.singularize}_create_asset_path".to_sym self.send(method_name, model, :type => @type, :format => :js) end |
#asset_file_name(asset) ⇒ Object
42 43 44 |
# File 'app/helpers/acts_as_assets/assets_helper.rb', line 42 def asset_file_name(asset) File.basename(asset.asset.path) end |
#asset_file_path(asset) ⇒ Object
45 46 47 |
# File 'app/helpers/acts_as_assets/assets_helper.rb', line 45 def asset_file_path(asset) asset.asset.url end |
#asset_id ⇒ Object
38 39 40 |
# File 'app/helpers/acts_as_assets/assets_helper.rb', line 38 def asset_id asset_target end |
#asset_label ⇒ Object
34 35 36 |
# File 'app/helpers/acts_as_assets/assets_helper.rb', line 34 def asset_label defined?(type_label).nil? ? @type.split('/').last.to_s.humanize : type_label end |
#asset_target ⇒ Object
14 15 16 |
# File 'app/helpers/acts_as_assets/assets_helper.rb', line 14 def asset_target @type.split('/').join('_') end |
#assets_body ⇒ Object
49 50 51 |
# File 'app/helpers/acts_as_assets/assets_helper.rb', line 49 def assets_body j render(:partial => @asset_partial, :locals => {:assets => Array(@assets), :model => @model}) end |
#destroy_file_path(asset, model) ⇒ Object
26 27 28 |
# File 'app/helpers/acts_as_assets/assets_helper.rb', line 26 def destroy_file_path(asset, model) destroy_path(asset, model, asset_target, @type) end |
#destroy_link(asset, model) ⇒ Object
30 31 32 |
# File 'app/helpers/acts_as_assets/assets_helper.rb', line 30 def destroy_link(asset, model) link_to(I18n.translate('destroy'), destroy_file_path(asset, model), {:method => :delete, :confirm => 'Sei Sicuro?', :remote => true}) end |
#destroy_method_for(asset) ⇒ Object
6 7 8 |
# File 'app/helpers/acts_as_assets/assets_helper.rb', line 6 def destroy_method_for(asset) "#{name_from(asset)}_destroy_asset_path".to_sym end |
#destroy_path(asset, model, target, type) ⇒ Object
2 3 4 |
# File 'app/helpers/acts_as_assets/assets_helper.rb', line 2 def destroy_path(asset, model, target, type) send(destroy_method_for(asset), model, {:asset_id => asset.id, :target => target, :type => type}) end |
#name_from(asset) ⇒ Object
10 11 12 |
# File 'app/helpers/acts_as_assets/assets_helper.rb', line 10 def name_from(asset) asset.class.base_model_name end |
#upload_complete_js_function ⇒ Object
18 19 20 |
# File 'app/helpers/acts_as_assets/assets_helper.rb', line 18 def upload_complete_js_function "function(id, fileName, responseJSON, qq){K.allegati.onComplete(id, fileName, responseJSON, qq,'#{asset_target}');}" end |