syk
syk

Reputation: 221

easiest way to set boolean admin attribute to users in the database? (Ruby on Rails)

I was trying to get Active Admin to work but unfortunately I may have to do this manually.

I want to set user 1 to be the admin. The user model does not have the :admin attribute listed.

It has

class User < ActiveRecord::Base
  attr_accessible :name, :email, :password, :password_confirmation

Is there a way I can go into the database and just change the admin value of user 1?

Thanks

Upvotes: 0

Views: 1536

Answers (2)

AMIC MING
AMIC MING

Reputation: 6354

quick and easy way to read Chapter 9.4.1 - Administrative users from Michael Hartl's Ruby on Rails Tutorial

Upvotes: 0

Richard Brown
Richard Brown

Reputation: 11444

You can do it from the console quickly:

rails console
u = User.find(1) # .first if it's not really id => 1, but the first record
u.admin = true
u.save

That will do it, but it's not repeatable, which I don't like. But for a one time fix it'll be ok.

Upvotes: 2

Related Questions