Ruby: SQLite3::BusyException: database is locked:

后端 未结 18 1047
感动是毒
感动是毒 2020-11-28 23:29

Ran into this error message whilst developing tonight: SQLite3::BusyException: database is locked:

I have two models:

  • Podcasts have many
18条回答
  •  猫巷女王i
    2020-11-29 00:06

    Try wrap cycle in a single transaction:

      def create_tracks
        json = Hashie::Mash.new HTTParty.get(self.json_url)    
        Track.transaction do
          json.sections.each do |section|
            if section.section_type=="track"
              Track.create(:name=>section.track.name, :podcast_id=>self.id)
            end
          end
        end             
      end
    

    (see Track.transaction)

提交回复
热议问题