Join Kevin Skoglund for an in-depth discussion in this video Form errors, part of Ruby on Rails 3 Essential Training.
Form errors are created when a form is submitted with data that doesn't pass all…the data validations that we've put in the model.…We'll discuss validating data in depth in the next chapter.…But while we are on the subject of forms let's go ahead and talk about how to…display any form errors that come up. So we can have some errors to look at…we'll start by using a simple validation.…I have validates_presence_of and then the attribute, which in this case I am…just going to use name.…So, we want to make sure there is some value present.…This is the most basic validation that there is.…
If it turns out that the form has been submitted without the name value present,…then it will add an error into the array of errors on the object.…So, if we are working with subject it would be subject.errors,…page.errors, section.errors.…Each active record object has its own array of errors and then if a create or…an update fails we'll be able to examine that array of errors to see what went wrong.…There are some other useful methods for errors that we can look at.…
- Understanding MVC (Model View Controller ) architecture
- Routing browser requests through the framework
- Responding to requests with dynamic content
- Defining associations and database relationships
- Creating, reading, updating and deleting records
- Working with forms
- Validating form data
- Reviewing built-in security features
- Authenticating users and managing user access
- Debugging and error handling
Skill Level Beginner
1. What Is Ruby on Rails?
2. Installing Ruby on Rails on a Mac
3. Installing Ruby on Rails on a Windows Machine
4. Getting Started
5. Controllers, Views, and Dynamic Content
6. Databases and Migrations
7. Models, ActiveRecord, and ActiveRelation
9. Controllers and CRUD
10. Layouts, Partials, and View Helpers
12. Data Validation
13. User Authentication
14. Improving the Simple CMS
15. Debugging and Error Handling
16. Introducing More Advanced Topics
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
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.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.