From the course: Ruby on Rails 6 Essential Training
Unlock the full course today
Join today to access over 22,500 courses taught by industry experts or purchase this course individually.
Create action: Create - Ruby on Rails Tutorial
From the course: Ruby on Rails 6 Essential Training
Create action: Create
- [Instructor] In this movie, we will write the create action and learn to process form values. In the previous movie, we added the new action. New and create work together as a pair, and together they make up the create portion of CRUD. New displays the form, create processes the form. Let's look at the four main steps in form processing. First, we need to instantiate a new object using the form parameters. Then, we attempt to save that object. If the save succeeds, we're going to redirect the user somewhere. In our case, we're going to redirect them to the index action. If the save fails, then we want to redisplay the form to allow the user to fix the problems and resubmit it. You might be wondering how could the save fail? Well, we haven't put any data validation into our application yet, but eventually we would. Data validation ensures that the data being received matches the criteria we want to allow. For example…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
-
(Locked)
Read action: Index4m 20s
-
(Locked)
Read action: Show4m
-
(Locked)
Adding basic forms to templates4m 51s
-
(Locked)
Create action: New4m 12s
-
(Locked)
Create action: Create5m 5s
-
(Locked)
Using strong parameters to regulate input4m 57s
-
(Locked)
Update actions: Edit and update6m 19s
-
(Locked)
Using partials and helpers to organize code6m 36s
-
(Locked)
Delete actions: Delete and destroy5m 50s
-
(Locked)
Challenge: Pages CRUD1m 23s
-
(Locked)
Solution: Pages CRUD4m 50s
-
(Locked)
-