Module: Admin::ResourceHelper
- Defined in:
- app/helpers/admin/resource_helper.rb
Instance Method Summary collapse
- #attachment_content_type(download) ⇒ Object
- #attachment_url(download) ⇒ Object
- #language_collection_options ⇒ Object
- #related_resource_type(resource) ⇒ Object
- #resource_status(resource) ⇒ Object
Instance Method Details
#attachment_content_type(download) ⇒ Object
5 6 7 |
# File 'app/helpers/admin/resource_helper.rb', line 5 def (download) t("content_type.#{download.content_type}") rescue download.content_type end |
#attachment_url(download) ⇒ Object
9 10 11 12 13 14 15 |
# File 'app/helpers/admin/resource_helper.rb', line 9 def (download) if download.url.present? download.url.sub('public://', 'http://k12-content.s3-website-us-east-1.amazonaws.com/') else download.file.url end end |
#language_collection_options ⇒ Object
17 18 19 |
# File 'app/helpers/admin/resource_helper.rb', line 17 def Language.order(:name).map { |lang| [lang.name, lang.id] } end |
#related_resource_type(resource) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'app/helpers/admin/resource_helper.rb', line 26 def (resource) resource_types = resource.resource_types.pluck(:name) if resource_types.include?('video') t('resource_types.video') else t('resource_types.resource') end end |
#resource_status(resource) ⇒ Object
21 22 23 24 |
# File 'app/helpers/admin/resource_helper.rb', line 21 def resource_status(resource) status = resource.hidden? ? :hidden : :active t(status, scope: :resource_statuses) end |