Add comment functionality to tracks
This commit is contained in:
parent
770a63e15c
commit
58208c73ac
19 changed files with 153 additions and 48 deletions
10
db/migrate/20190720062321_add_comments_count_to_tracks.rb
Normal file
10
db/migrate/20190720062321_add_comments_count_to_tracks.rb
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue