Added migration to fix incorrectly hidden todos

Signed-off-by: Reinier Balt <lrbalt@gmail.com>
This commit is contained in:
mike 2009-01-19 01:22:35 +08:00 committed by Reinier Balt
parent a634206e5f
commit 6bc68bcf6c

View file

@ -0,0 +1,18 @@
class FixIncorrectlyHiddenTodos < ActiveRecord::Migration
def self.up
hidden_todos_without_project =
Todo.find(:all, :conditions => "state='project_hidden' AND project_id IS NULL")
active_projects = Project.find(:all, :conditions => "state='active'")
hidden_todos_in_active_projects =
Todo.find(:all, :conditions => ["state='project_hidden' AND project_id IN (?)", active_projects])
todos_to_fix = hidden_todos_without_project + hidden_todos_in_active_projects
todos_to_fix.each do |todo|
todo.update_attribute :state, 'active'
end
end
def self.down
end
end