Joe Smith
Joe Smith

Reputation: 244

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.

Upvotes: 3

Views: 3079

Answers (2)

Paul Lenkiewicz
Paul Lenkiewicz

Reputation: 11

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

variable.save

Upvotes: 1

Nermin
Nermin

Reputation: 6100

User.first.update :admin => true

Upvotes: 5

Related Questions