Home>

I want to ask a question

  • Is there a way to register records at the migration stage?

is

I am creating a web application with a user management system with rails
Therefore, there is a problem that cannot be solved for the part that manages the user's place of residence.
The user registers the address at the new registration stage, but for prefectures, I would like to register it in a separate column because it may be used independently within the service.
So, I would like to take the form of selecting only 47 prefectures from the pull-down list at the time of registration, but I am worried about whether to describe all 47 prefectures on the front side or create a prefecture table.

If i leave the processing to the front side, the amount of description will increase, so I think that it is a good idea to consider future function implementation.
However, when I create a table, I'm not sure how to add records for each prefecture when deploying to a production environment.
I would like to have a method to automatically add records when migrating at the time of deployment, but I would like to know if there is such a method.

Also, I would be grateful if you could tell me how to manage prefectures in web applications in general.

  • Answer # 1

    I would like to have a method to automatically add records when migrating at the time of deployment, but I would like to know if there is such a method.
    Also, I would be grateful if you could tell me how to manage prefectures in web applications in general.

    Ichiou, you can mix it with migration, but the initial data isseedBut write it somewhere elsebin/rake db: seedIt is common to input with a command like.