Learn to implement a basic “create” action by writing controller code and the related HTML for the view template. The create action is a Create operation that adds a new record to the database.
- [Narrator] In this movie, we'll 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.…Next, we attempt to save that object.…If the save succeeds, we will redirect the user somewhere.…
In our case, we would redirect to the index action.…If the save fails, then we want to re-display the form…so that the user can fix the problems…and resubmit the form.…You might be wondering how the save could fail.…We haven't put any data validation into our application yet…but eventually we will.…Data validation ensures the data received from the form…matches the criteria of the data we want to allow…to go in the database.…For example, if we want to limit the subject's name…to be a maximum of 50 characters,…then we add data validation, which would raise an error…
- Creating and configuring a new Ruby on Rails project
- Generating controllers and views
- Handling server requests
- Using different types of routes
- Rendering and viewing templates
- Generating migrations and models
- Creating, updating, and deleting records
- Finding records with queries
- Understanding relationship types
- Writing controllers for CRUD
- Working with layouts and helpers
- Managing application assets
- Building forms
- Validating data
- Authenticating users
Skill Level Beginner
1. What Is Ruby on Rails?
2. Get Started
3. Controllers, Views, and Dynamic Content
4. Databases and Migrations
5. Models and ActiveRecord
7. CRUD, REST, and Resourceful Routes
8. Controllers and CRUD
9. Layouts, Partials, and View Helpers
12. Data Validation
13. Controller Features
14. User Authentication
15. Improve the Simple CMS
Next steps1m 44s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.