Reputation: 41
I am trying to add a new field called username to my admin_user model. I am using ActiveAdmin in my application. I am not sure how to add it?
Upvotes: 0
Views: 871
Reputation: 1896
You can do it using these two commands:
rails generate migration add_username_to_admin_user username:string
rake db:migrate
The first line is a shortcut for adding a field to a table (add_username_to_admin_user
). It will produce something like this:
class AddUsernameToAdminUser < ActiveRecord::Migration
def change
add_column :admin_users, :username, :string
end
end
The second line applies the migration to your database.
You might also want to review the migration documentation for more in-depth information (as always, Caveat Emptor: Rails documentation is notoriously out of date).
Upvotes: 1
Reputation: 5060
You need to add it to your schema (use rails g migration
), update your DB (rake db:migrate
) and then active admin will see the field.
Upvotes: 0