Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7750565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:19:26+00:00 2026-06-01T11:19:26+00:00

I have a Rails 3.2.2 application using Ruby version 1.9.2. I have created basic

  • 0

I have a Rails 3.2.2 application using Ruby version 1.9.2. I have created basic authentication for my users by following the tutorial on Railscasts.

I don’t need anything complicated, such as remember me or password resets and I would like to have a good understanding with what’s actually going on before I look into using Devise or anything similar.

At the moment I have user accounts and I can check if the user is logged in by using

<% if current_user %>

So I would like to be able to do

<% if current_user.admin? %>

If I use the above admin? check I get the following error:

undefined method `admin?'

My understanding was that the above checks if the admin is true for the current user. I’ve added an admin column to my user table that’s boolean and set to default = false.

create_table :users do |t|
  t.string :name
  t.string :initials
  t.string :email
  t.string :password_digest
  t.boolean :admin, :default => false

I have also added the admin column to my seed file so I can have a test admin account

User.create(name: 'Danny', initials: 'DAN', email: 'danny@railsapplication.co.uk', password: 'secret', admin: 'true')

As I have added an admin user, and I’m checking for the boolean value to be true I thought that would be all I needed to do.

Am I missing something?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T11:19:28+00:00Added an answer on June 1, 2026 at 11:19 am

    If you’ve tried to add an admin column to your table by editing the original migration, you’ll have to run rake db:rollback to drop the users table, and then rake db:migrate to bring the table back with the admin column in place.

    You can’t edit migrations this way and expect the results to appear in the database automatically. If you want to add columns to a table, you need to generate a second migration:

    $ rails g migration AddAdminToUsers
    

    And then use the add_column helper:

    class AddAdminToUsers < ActiveRecord::Migration
      def change
        add_column :users, :admin, :boolean, :default => false
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a blog application using Ruby on Rails which includes the ability
I have created a blog application using Ruby on Rails and have just added
I have built a very simple blog application using Ruby on Rails. New to
I have built a blog application using Ruby on Rails. In the application I
I'm using Ruby on Rails (Edge, the development version), and Ruby rvm 1.9.2. application.js
I have build a standard Rails 3 application (using Ruby 1.9.2). I placed all
I working on Ruby on Rails application using a PostgreSQL database. I have heard
I have developed a Ruby on Rails application and successfully deployed on Weblogic using
I have a Ruby application (not using Rails) that use my own Ruby gems.
I have an application using Ruby on Rails where a user will be providing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.