lib/locomotive/custom_fields.rb in locomotive_cms-2.0.0.rc9 vs lib/locomotive/custom_fields.rb in locomotive_cms-2.0.0.rc10
- old
+ new
@@ -28,9 +28,21 @@
# Set correct paths
def store_dir
"sites/#{model.site_id}/content_#{model.class.model_name.demodulize.underscore}/#{model.id}/files"
end
+ # In some situations, for instance, for the notification email when a content entry is created,
+ # we need to know the url of the file without breaking the upload process.
+ # Actually, the uploaded file will be written on the filesystem after the email is sent.
+ #
+ # @return [ String ] The url to the soon uploaded file
+ #
+ def guess_url
+ this = self.class.new(model, mounted_as)
+ this.retrieve_from_store!(model.read_uploader(mounted_as))
+ this.url.to_s
+ end
+
def cache_dir
"#{Rails.root}/tmp/uploads"
end
end