Reputation: 127
I'm working on a sign-up app in Rails, and I'm using active admin to manage it. New attributes added to the model aren't showing in active admin.
I've decided to add an attribute to one of the models and I've added it in the db folder. I've then run db:migrate.
However, the new attribute is not appearing in admin view.
Here is my code from the create file:
class CreateRegistrations < ActiveRecord::Migration[5.0]
def change
create_table :registrations do |t|
t.string :first_name
t.string :last_name
t.string :gender
t.string :email
t.string :nationality
t.string :religion
t.date :birthdate
t.string :phone
t.string :streetname
t.string :city
t.string :state
t.string :zip
t.boolean :need_ride
t.string :has_spouse
t.string :spouse_name
t.string :english_level
t.text :expectations
t.string :length_of_stay
t.text :exact_length
t.integer :volunteer_partner
t.boolean :matched
t.timestamps
end
end
end
I've added the last attribute- :matched, to params and to permitted params in both the controller and in the admin model.
It still is not showing up.
Any thoughts, suggestions?
Thanks in advance.
Upvotes: 0
Views: 566
Reputation: 466
This is because the migration CreateRegistrations
already ran, when you first create the registration
table. After running a migration if you change that migration file and run db:migrate
again it won't see the update you did to that migration file.
To add the new attribute you should create a new migration file by running the following command:
rails generate migration AddMatchedToYourModel matched:boolean
It should create a new migration file. And then run rails db:migrate
again.
Upvotes: 1