Programming Ruby on Rails

How to add admin by default while create rails migration

Sometimes in our app, we have not any registration page for signup because the system is based on like one admin & he/she can add users & users just use the login page directly & not necessary for registration page or something like this, so how can we add this one admin while the project setup/migrate to our server.

Open up the seeds.rb file & add something like this

User.create(first_name: "Example", last_name: "Admin", 
            email: "[email protected]", 
            password: "12345678", 
            is_admin: true)

update this line as your requirements.

Then run this command after database migration.

rails db:seed



Fool Dev

I didn't get trained by the school system like other kids, and when I did concentrate on learning, my mind was cluttered and locked by the programming of the system. © Huey Newton