Module: Assetable::Uploaders
- Included in:
- GalleryInput, UploaderInput
- Defined in:
- lib/assetable/inputs/uploaders.rb
Instance Method Summary collapse
- #asset_preview(asset, type = :asset, fieldname = nil) ⇒ Object
- #directions_html ⇒ Object
-
#gallery_preview(fieldname) ⇒ Object
Gallery preview is a set of assets.
Instance Method Details
#asset_preview(asset, type = :asset, fieldname = nil) ⇒ Object
19 20 21 |
# File 'lib/assetable/inputs/uploaders.rb', line 19 def asset_preview asset, type=:asset, fieldname=nil ActionController::Base.new.send(:render_to_string, partial: "assetable/shared/templates/#{type.downcase.to_s}_item", locals: { asset: asset, fieldname: fieldname }) end |
#directions_html ⇒ Object
23 24 25 |
# File 'lib/assetable/inputs/uploaders.rb', line 23 def directions_html ActionController::Base.new.send(:render_to_string, :partial => 'assetable/assets/directions') end |
#gallery_preview(fieldname) ⇒ Object
Gallery preview is a set of assets. Let’s loop over the assets in the gallery and create a preview for each.
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/assetable/inputs/uploaders.rb', line 5 def gallery_preview fieldname if modal_gallery = object.send("#{attribute_name}") gallery = "" # modal_gallery.assets.each do |asset| modal_gallery..each_with_index do |, index| # gallery += asset_preview(asset, :gallery, fieldname) gallery += ActionController::Base.new.send(:render_to_string, partial: "assetable/shared/templates/gallery_item", locals: { asset: .asset, asset_attachment: , fieldname: fieldname, index: index }) end gallery end end |