077_fix_userless_articles.rb
上传用户:netsea168
上传日期:2022-07-22
资源大小:4652k
文件大小:0k
源码类别:
Ajax
开发平台:
Others
- class FixUserlessArticles < ActiveRecord::Migration
- def self.up
- unless $schema_generator
- articles = Article.find(:all)
- STDERR.puts "Fixing articles with empty user_id"
- articles.each do |article|
- if article.user.nil?
- STDERR.puts "Fixing article #{article.id} having empty user"
- article.user_id = 1
- article.save!
- end
- end
- end
- end
- def self.down
- end
- end