Last active
December 15, 2015 17:20
-
-
Save awead/5296086 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NB: A collection has many series, a series is part of one collection. | |
This doesn't work. After reloding the collection, it still has the same number of series: | |
> c = ArchivalCollection.find("arc:test") | |
=> #<ArchivalCollection pid:"arc:test", title:"Test Collection", format:"Collection"> | |
> c.series.count | |
=> 3 | |
> c.series.pop | |
=> #<ArchivalComponent pid:"arc:testref3", title:"Series 1: Sample Series"> | |
> c.save | |
=> true | |
> c.series.count | |
=> 2 | |
> c = ArchivalCollection.find("arc:test") | |
=> #<ArchivalCollection pid:"arc:test", title:"Test Collection", format:"Collection"> | |
> c.series.count | |
=> 3 | |
This works by setting the parent collection to nil on the series (child). | |
Here, I just arbitrarily delete the last series object from the collection: | |
> c = ArchivalCollection.find("arc:test") | |
=> #<ArchivalCollection pid:"arc:test", title:"Test Collection", format:"Collection"> | |
> c.series.count | |
=> 3 | |
> c.series.last.collection = nil | |
=> nil | |
> c.series.last.save | |
=> true | |
> c.save | |
=> true | |
> c = ArchivalCollection.find("arc:test") | |
=> #<ArchivalCollection pid:"arc:test", title:"Test Collection", format:"Collection"> | |
> c.series.count | |
=> 2 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment