Commit b5e559775562435f554d357d9b90fe49126db621
1 parent
2951f562
Exists in
master
and in
2 other branches
Add migration to add communities_ratings_block to all softwares
Signed-off-by: Fabio Teixeira <fabio1079@gmail.com>
Showing
1 changed file
with
30 additions
and
0 deletions
Show diff stats
db/migrate/20150904181508_add_communities_ratings_block_to_all_softwares_communities.rb
0 → 100644
... | ... | @@ -0,0 +1,30 @@ |
1 | +class AddCommunitiesRatingsBlockToAllSoftwaresCommunities < 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 | + ratings_block = CommunitiesRatingsBlock.new :mirror => true, :move_modes => "none", :edit_modes => "none" | |
8 | + ratings_block.settings[:fixed] = true | |
9 | + ratings_block.display = "home_page_only" | |
10 | + ratings_block.save! | |
11 | + print "." | |
12 | + | |
13 | + software_area_one.blocks << ratings_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 | + ratings_block.position = last_block_position + 1 | |
20 | + ratings_block.save! | |
21 | + print "." | |
22 | + end | |
23 | + | |
24 | + puts "" | |
25 | + end | |
26 | + | |
27 | + def down | |
28 | + CommunitiesRatingsBlock.destroy_all | |
29 | + end | |
30 | +end | ... | ... |