Rails Save Record into Database
We can save data into database using Ruby on Rails. Let's see an example to save data of a form into database.
Step 1 Create a new Rails application.
Step 2 Change your directory to login.
Step 3 Create scaffold from the console.
Step 4 Migrate your database.
Step 5 Go to Gemfile and uncomment the following line.
Step 6 Run the following command:
Step 7 Go to app/controllers/users_controller.rb and write the following code in create method.
Step 8 Go to app/views/users/index.html.erb file.
Step 9 Go to app/views/users/new.html.erb file.
Step 10 Go to app/views/users/_form.html.erb file.
Step 11 Start the Rails server.
Step 12 Run it on localhost.
Click on New Use to add a new user.
Click on Create Use to add a new user.
DownloadDownload this example
Next TopicRuby on Rails View Record