mardi 2 juin 2015

appending to rails field value

I need to find and update a number of records in a Rails 3.2, Ruby 2 application. The following code successfully finds the records I want. What I need to do though is add " x" (including the space) to the email address of every user and I can't figure out how to do it.

This finds the records

User.joins(:account)
  .where("users.account_id NOT IN (?)", [1955, 3083, 3869])
  .where("accounts.partner_id IN (?)", [23,50])
  .where("users.staff = '0'")
  .where("users.admin = '0'")
  .where("users.api_user = '0'")
  .where("users.partner_id is null")
  .update_all(email: :email.to_s << " X")

but it's the last line I'm having problems with. Is this possible, or do I need to find the records another way?

Aucun commentaire:

Enregistrer un commentaire