今晚开发时遇到此错误消息: SQLite3::BusyException: database is locked:
我有两个型号:
要创建播客:
我正在尝试使用我的rails应用程序来利用json feed还详细说明属于此Podcast的曲目的名称(和艺术家)这一事实.
我认为以下before_validation方法会在我们创建新的Podcast时自动创建所有关联的Tracks.
class Podcast < ActiveRecord::Base
attr_accessible :mixcloud_url, :lots, :of, :other, :attrs
has_many :tracks
before_validation :create_tracks
def create_tracks
json = Hashie::Mash.new HTTParty.get(self.json_url)
json.sections.each do |section|
if section.section_type=="track"
Track.create(:name=>section.track.name, :podcast_id=>self.id)
end
end
end
end
Run Code Online (Sandbox Code Playgroud)
我怎么能绕过这个?看起来rails(或sqlite3)不喜欢以这种方式创建关联模型的新实例.我怎么能这样做?我怀疑这是一个像sqlite3一样的rails问题.我可以发布更多代码,如果它会有所帮助.