Commit 007f77bf29df99f4423ddad1646ce27c9a958242

Authored by Fabio Teixeira
1 parent b5e55977

Add migration to add software_tab_data_block to all softwares

Signed-off-by: Fabio Teixeira <fabio1079@gmail.com>
db/migrate/20150904202116_add_software_tab_data_block_to_all_softwares.rb 0 → 100644
... ... @@ -0,0 +1,30 @@
  1 +class AddSoftwareTabDataBlockToAllSoftwares < ActiveRecord::Migration
  2 + def up
  3 + Community.joins(:software_info).each do |software_community|
  4 + software_area_one = software_community.boxes.find_by_position 1
  5 + print "."
  6 +
  7 + soft_tab_block = SoftwareTabDataBlock.new :mirror => true, :move_modes => "none", :edit_modes => "none"
  8 + soft_tab_block.settings[:fixed] = true
  9 + soft_tab_block.display = "except_home_page"
  10 + soft_tab_block.save!
  11 + print "."
  12 +
  13 + software_area_one.blocks << soft_tab_block
  14 + software_area_one.save!
  15 + print "."
  16 +
  17 + # Puts the ratings block as the last one on area one
  18 + last_block_position = software_area_one.blocks.order(:position).last.position
  19 + soft_tab_block.position = last_block_position + 1
  20 + soft_tab_block.save!
  21 + print "."
  22 + end
  23 +
  24 + puts ""
  25 + end
  26 +
  27 + def down
  28 + SoftwareTabDataBlock.destroy_all
  29 + end
  30 +end
... ...