Class: Cdtb::FixNicknameJob

Inherits:
ApplicationJob
  • Object
show all
Defined in:
app/jobs/cdtb/fix_nickname_job.rb

Overview

Fixes the nickname of the Decidim::User with the given ‘user_id`.

Instance Method Summary collapse

Instance Method Details

#perform(user_id) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'app/jobs/cdtb/fix_nickname_job.rb', line 8

def perform(user_id)
  user= Decidim::User.find(user_id)
  previous= user.nickname

  nickname = Decidim::User.nicknamize(previous, organization: user.organization)
  user.update_attribute(:nickname, nickname)

  Rails.logger.info "#{user.id}-#{user.email}: #{previous} => #{user.nickname}"
end