Add comment functionality to tracks

This commit is contained in:
Rishabh Singh 2019-07-18 12:49:50 +05:30
parent 770a63e15c
commit 58208c73ac
19 changed files with 153 additions and 48 deletions

View file

@ -0,0 +1,10 @@
class AddCommentsCountToTracks < ActiveRecord::Migration[5.1]
def change
add_column :tracks, :comments_count, :integer, default: 0, null: false
Track.find_each do |track|
comments_count = track.comment_threads.count
track.update_attributes(:comments_count, comments_count) unless comments_count.zero?
end
end
end