launchscout / nku

NKU Class Spring
5 stars 14 forks source link

Creating an administrator #85

Closed beisert1 closed 10 years ago

beisert1 commented 10 years ago

I am a bit confused on how to make a current user an admin.

I have the following code in my seeds.rb file: (in my actual code I have the name, nickname, email, and password of the account I have created and signed up on my site.)

if Student.where(admin: true).count.zero?
  Student.create!(name: "name here nickname: "nickname here" email: "email here" password: "password here", password_confirmation: "password here", admin: true)
end

Is there something I am missing or misspelling?

Original code used User instead of Student. Also should I change admin: true to is_admin: true since that is what I use on my site??

beisert1 commented 10 years ago

I changed admin to is_admin and I added commas in between name, nickname, etc.

And I ran rake db:seed from console.

It didn't give me any errors or anything but my account still doesn't seem to be promoted to a administrator account.

rockwood commented 10 years ago

You can do it through the rails console

rails console
s = Student.find_by_email("your@email")
s.admin = true
s.save
beisert1 commented 10 years ago

Thanks!