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 7718497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:10:53+00:00 2026-06-01T03:10:53+00:00

I have a class User in Rails using Mongoid and Devise. I can’t seem

  • 0

I have a class User in Rails using Mongoid and Devise. I can’t seem to figure out how to add an Admin role. The How To on the platformtec (Devise) site wants me to run a standard Rails migration, but that’s not working because of Mongoid.

Can anyone point me in the correct direction?

Here’s my user.rb (minus the modules commented out):

class User
    include Mongoid::Document
    # Include default devise modules.
    devise :database_authenticatable, :registerable,
      :recoverable, :rememberable, :trackable, :validatable

    ## Database authenticatable
    field :email,              :type => String, :null => false, :default => ""
    field :encrypted_password, :type => String, :null => false, :default => ""

    ## Recoverable
    field :reset_password_token,   :type => String
    field :reset_password_sent_at, :type => Time

    ## Rememberable
    field :remember_created_at, :type => Time

    ## Trackable
    field :sign_in_count,      :type => Integer, :default => 0
    field :current_sign_in_at, :type => Time
    field :last_sign_in_at,    :type => Time
    field :current_sign_in_ip, :type => String
    field :last_sign_in_ip,    :type => String


    ## Token authenticatable
    # field :authentication_token, :type => String
    field :name
    validates_presence_of :name
    validates_uniqueness_of :name, :email, :case_sensitive => false
    attr_accessible :name, :email, :password, :password_confirmation, :remember_me
end

Thanks,
Charlie Magee

  • 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-01T03:10:54+00:00Added an answer on June 1, 2026 at 3:10 am

    You just need add an admin field in Boolean so in your class User add this line :

    field :admin, :type => Boolean, :default => false
    

    it’s exactly the same this migration in AR:

    class AddAdminToUsers < ActiveRecord::Migration
      def self.up
        add_column :users, :admin, :boolean, :default => false
      end
    
      def self.down
        remove_column :users, :admin
      end
    end
    

    After this adding, all method about admin in the devise wiki works fine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Rails 3.2. I have following models: Blog Comment User class Blog
I am using Devise in Rails 3, and have a User model in rails
I have two entities, projects and users. These are modeled in Rails using Mongoid
I'm using Rails 3. I have 3 models: class Deal < ActiveRecord::Base has_many :wishes,
I have a one-to many relationship in Rails: class User < ActiveRecord::Base has_many :activities,
I have a class User with one field called birthDate which is a java.sql.Date
I have a class: public class User { public virtual int Id { get;
I have this Class: public class User { public string id{ get; set; }
I have a class User that looks like this: class User { private: char*
I have following code class User attr_accessor :name end u = User.new u.name =

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.