app/models/cas/media_file.rb in cas-cms-0.1.2 vs app/models/cas/media_file.rb in cas-cms-0.1.3
- old
+ new
@@ -13,9 +13,13 @@
scope :cover, ->{ where(cover: true) }
scope :non_cover, ->{ where(cover: false) }
scope :usable, -> { where.not(attachable_id: nil) }
+ def site
+ attachable.site || raise("Attachable doesn't have a Cas::Site association")
+ end
+
def url(version:, use_cdn: true)
cdn = ENV.fetch("CDN_HOST", nil) if use_cdn
# When `path` is present, it means no gem was used for uploads, therefore
# the image has to be treat as raw URL.