Removing full name on all users


Hi there, I’ve had some issues importing the full names from a mybb installation and I want to delete all the users full names so they can correct them later from their own preferences. I want to run the following command on the rails console:

User.all.each do |u| = ""

Is this the correct syntax?

(Régis Hanol) #2

While this would work, it will take a lot of time if you have a large number of users.

You should use this instead :wink:

User.update_all(name: "")


Thank you! so just to be sure, it’s

 User.update_all(name: "")

without the = ""

right? Would this also work for changing email preferences? Like

 User.update_all(email_direct: false)

(Régis Hanol) #4

Launch the rails console and then just write

User.update_all(name: "", email_direct: false)