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

  • Home
  • SEARCH
  • 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 6687345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:16:40+00:00 2026-05-26T05:16:40+00:00

rails generate devise User I got this=> class DeviseCreateUsers < ActiveRecord::Migration def self.up create_table(:users)

  • 0

rails generate devise User I got this=>

class DeviseCreateUsers < ActiveRecord::Migration
  def self.up
    create_table(:users) do |t|
      t.database_authenticatable :null => false
      t.recoverable
      t.rememberable
      t.trackable

      # t.encryptable
      # t.confirmable
      # t.lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both
      # t.token_authenticatable


      t.timestamps
    end

    add_index :users, :email,                :unique => true
    add_index :users, :reset_password_token, :unique => true
    # add_index :users, :confirmation_token,   :unique => true
    # add_index :users, :unlock_token,         :unique => true
    # add_index :users, :authentication_token, :unique => true
  end

  def self.down
    drop_table :users
  end
end

But i want to create a users table with username, email, password, role, group, mark, created_at, modified_at columns.

How can i do this ?

Is this structure correct to have username, password, email, group, role, mark ?

class DeviseCreateUsers < ActiveRecord::Migration
  def self.up
    create_table(:users) do |t|
      t.database_authenticatable :null => false
      t.recoverable
      t.rememberable
      t.trackable

      # t.encryptable
      # t.confirmable
      # t.lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both
      # t.token_authenticatable

      t.string :username
      t.string :password
      t.string :email
      t.string :group
      t.string :role
      t.integer :mark

      t.timestamps
  end

    add_index :users, :email,                :unique => true
    add_index :users, :reset_password_token, :unique => true
    # add_index :users, :confirmation_token,   :unique => true
    # add_index :users, :unlock_token,         :unique => true
    # add_index :users, :authentication_token, :unique => true
  end

  def self.down
    drop_table :users
  end
end

What are these?

t.database_authenticatable :null => false
          t.recoverable
          t.rememberable
          t.trackable
  • 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-05-26T05:16:41+00:00Added an answer on May 26, 2026 at 5:16 am

    You can perform a migration to add some fields to the user table.
    For example:

    rails g add_fields_to_users username:string # as well as other fields you need
    

    Then, in order to add columns to your table run:

    rake db:migrate
    

    Devise has already generated some columns you need like: email, password, created_at, updated_at…

    For adding roles to your user model you should watch the cancan screencast: railscasts and also read the doc in order to see some updates.

    EDIT:

    If you want to add fields manually you could add them in your self.up method before running your migration:

    def self.up
      create_table(:users) do |t|
    
        #...
    
        t.rememberable
        t.trackable
    
        t.string :username
        #... your other attributes here
    
      end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've employed devise as the user-authentication gem for my rails web-app. Using this pre-generated
I'm following this tutorial (seems good) for Rails. After I run ruby script/generate scaffold
I'm using this command: rails generate model DayOfMonth day:integer Rails generated the model DayOfMonth
I use Rails 3.0.3 and devise 1.1.5 ( devise on github ) My User
After creating a migration file with rails generate migration AddClientToUser I can edit my
I've generated a simple Rails 3 class using the scaffold function: rails generate scaffold
I'm creating a Rails app using Devise for user management (Rails 3.0.10, Devise 1.4.2).
Devise Authentication gem ( http://github.com/plataformatec/devise ) is a Rails tool to authenticate a user
Ruby on Rails has a lot of ways to generate JavaScript. Particularly when it
In Rails, I'm coding a series of controllers to generate XML. Each time I'm

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.