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

Create action: Create - Ruby on Rails Tutorial

From the course: Ruby on Rails 6 Essential Training

Start my 1-month free trial

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…

Contents