Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set admin attribute to true in rails console (pry)?

Right now when I change User.first.admin = false, to User.first.admin = true it does not save. Even if I run User.first.save afterwards. While if I make

variable = User.first
variable.admin = true
variable.admin

it will return true(default is false)

But the user in my actual application is still not given the extra features they would be if admin = true, so how do I properly set admin to true for my first User in the rails console(with pry) ? Thanks for the help.

like image 257
Joe Smith Avatar asked Dec 06 '25 18:12

Joe Smith


2 Answers

User.first.update :admin => true
like image 66
Nermin Avatar answered Dec 08 '25 07:12

Nermin


Alternatively, after variable.admin = true, you can just run

variable.save
like image 24
Paul Lenkiewicz Avatar answered Dec 08 '25 06:12

Paul Lenkiewicz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!