049_move_feedback_to_new_state_machine.rb
上传用户:netsea168
上传日期:2022-07-22
资源大小:4652k
文件大小:1k
源码类别:
Ajax
开发平台:
Others
- class MoveFeedbackToNewStateMachine < ActiveRecord::Migration
- class Content < ActiveRecord::Base
- include BareMigration
- end
- def self.up
- return if $schema_generator
- Content.find(:all,
- :conditions => ['type = ? or type = ?',
- 'Trackback', 'Comment']).each do |c|
- c.state = if c.published?
- 'ContentState::PresumedHam'
- else
- 'ContentState::PresumedSpam'
- end
- c.save!
- end
- end
- def self.down
- return if $schema_generator
- Content.find(:all,
- :conditions => ['type = ? or type = ?',
- 'Trackback', 'Comment']).each do |c|
- c.state = if c.published?
- 'ContentState::Published'
- else
- 'ContentState::Withdrawn'
- end
- c.save!
- end
- end
- end