So to get a record in the User model I run
 @user = User.find(1)
Then to change an attribute:
 @user.active = false
It then returns false
When I run
 @user.save
I get
(0.2ms)  BEGIN
(0.3ms)  SELECT 1 FROM `users` WHERE (LOWER(`users`.`username`) = LOWER('sean') AND `users`.`id` != 1) LIMIT 1
(0.3ms)  SELECT 1 FROM `users` WHERE (LOWER(`users`.`email`) = LOWER('[email protected]') AND `users`.`id` != 1) LIMIT 1
(0.6ms)  ROLLBACK
 => false 
                Try this to see if errors are being thrown
@user.save!
If your @user.save is returning false then it means there's an error and something is preventing it from being saved. You can use @user.errors at that point to see what the errors are.
Had the same issue. Doing this managed to solve it:
@user.save(validate: false)
Here is the link to original answer: How to skip validations as admin during update_attributes?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With