ualbertalib / jupiter

Jupiter is a University of Alberta Libraries-based initiative to create a sustainable and extensible digital asset management system. This is phase 2 (Digitization).
https://era.library.ualberta.ca/
MIT License
23 stars 10 forks source link

Seeds failing issue on Integration branch #2428

Closed murny closed 3 years ago

murny commented 3 years ago

Seeds are currently failing here:

  11.times do |_i|
    Digitization::Book.new(peel_id: rand(1..3400), part_number: rand(1..100),
                              owner_id: admin.id,
                              dates_issued: [rand(1900..2020).to_s],
                              date_ingested: '2016-12-08T06:00:00.000Z',
                              title: "#{Faker::Company.name} #{Faker::WorldCup.city} Music Festival",
                              alternative_titles: [Faker::Hipster.sentence.to_s],
                              resource_type: ControlledVocabulary.digitization.resource_type.from_value('Text'),
                              genres: [ControlledVocabulary.digitization.genre.from_value('Programs (Publications)')],
                              languages: [ControlledVocabulary.digitization.language.from_value('English')],
                              publishers: [ControlledVocabulary.digitization.subject.from_value('Edmonton Folk Music Festival')],
                              places_of_publication: [ControlledVocabulary.digitization.location.from_value('Edmonton (Alta.)')],
                              extent: 'v. : ill. ; 22-27 cm.',
                              notes: ['Souvenir program of the festival, including biographical notes on and portraits and discographies of the performers, articles, etc.', Faker::Hipster.sentence.to_s],
                              temporal_subjects: ['1981'],
                              geographic_subjects: [ControlledVocabulary.digitization.location.from_value('Edmonton (Alta.)')],
                              topical_subjects: [ControlledVocabulary.digitization.subject.from_value('Folk music festivals')],
                              rights: ControlledVocabulary.digitization.rights.from_value('In Copyright')
    ).tap do |book|
      book.create_fulltext(text: Faker::Lorem.sentence(word_count: 250, supplemental: false, random_words_to_add: 0))
      book.save!
    end # Folk Fest
  end

This code is giving an ActiveRecord::RecordNotSaved: You cannot call create unless the parent is saved error on the book.create_fulltext(...).

I think if we change Digitization::Book.new to Digitization::Book.create and remove the book.save! then this should fix it 🤔

pgwillia commented 3 years ago

That should be fixed in the integration branch: https://github.com/ualbertalib/jupiter/blob/4243ad9cd7796000e18be20686b81c214d5777bb/db/seeds.rb#L710-L730

murny commented 3 years ago

My bad! This is fixed 😆