lib/siteleaf/document.rb in siteleaf-2.0.0.pre.beta7 vs lib/siteleaf/document.rb in siteleaf-2.0.0.pre.beta9
- old
+ new
@@ -1,15 +1,19 @@
module Siteleaf
class Document < Content
- attr_accessor :collection_id
+ attr_accessor :collection_path
def create_endpoint
- "collections/#{self.collection_id}/documents"
+ ::File.join("sites", site_id, "collections", collection_identifier, "documents")
end
def collection
- Collection.find(self.collection_id)
+ Collection.find(collection_identifier)
+ end
+
+ def collection_identifier
+ collection_path || directory.match(/_(.*)/).try(:last)
end
end
end
\ No newline at end of file