cirandas.net

ref: master

db/migrate/20100514133346_move_values_of_visible_field_to_display_field.rb


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
class MoveValuesOfVisibleFieldToDisplayField < ActiveRecord::Migration
  def self.up
    Block.all.each do |block|
      visible = block.settings.delete(:visible)
      if visible == false
        block.settings[:display] = 'never'
        block.save!
      else
        if block.settings[:display].blank?
          block.settings[:display] = 'always'
          block.save!
        end
      end
    end
  end

  def self.down
    say "Nothing to do!"
  end
end