Skip to content

Commit

Permalink
メンターをWatch中にするメソッドからinsert_allを削除
Browse files Browse the repository at this point in the history
  • Loading branch information
yamadaab committed Sep 16, 2021
1 parent 7af12de commit 6c7e7c6
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions app/controllers/questions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,12 @@ def questions_property
end

def create_mentors_watch
Watch.insert_all(watch_records)
end

def watch_records
User.mentor.map do |mentor|
{
watchable_type: 'Question',
watchable_id: @question.id,
created_at: Time.current,
updated_at: Time.current,
user_id: mentor.id
}
User.mentor.each do |mentor|
watch = Watch.new(
user: mentor,
watchable: @question
)
watch.save!
end
end
end

0 comments on commit 6c7e7c6

Please sign in to comment.