Adding custom fields to admin registration form using devise

Hi, I am learning Ruby on Rails development and I am implementing devise to register and create new admin accounts. The problem that I am facing is that I want to add new custom fields to the admin registration. I have done that and added some new custom fields, also I have mentioned them in the registrations controller of the admin, and added those fields in the migration file. I am trying to update the new.html.erb page to reflect the changes but it is not displaying the changes on the form. Kindly please help me, what should I do. My github repo

With some help I fixed the issue. Simply add the following line to devise.rb

config.scoped_views = true

Now that I have added the custom fields to the form, when I am trying to save the data it won’t get saved in the database and I am unable to sign in. I do not know why. I am using devise.

Although I think that I am using the right approach here, but I do not know whether it is the validation I have not activated that in the devise.rb for email. I am getting an error that the record is not being saved to the database.

sign up form

Although the transaction works in the registration controller but it does not save any data and the record is empty. I do not understand why is that the case.

The issue has been resolved. I removed the attr_accessor in the admin model. Since devise and the active record storage were already handling the issue. There is no need to set the getters and setters in their again.

Perhaps you could also skip using Devise by using the new Rails 7.1 authentication helpers.

The same issue :expressionless: Can anyone solve it?