Generating HTML select-option tags can be tedious. There can be many options, each with a value and text, and each one must determine if it is the currently selected option. Rails has a select helper method that make this process much simpler.
- [Instructor] In addition to the form helpers…we saw on the last movie,…Rails also offers us form helpers…to work with select option tags,…that is when a form needs a pulldown menu of options…that a user can choose from.…We will begin by looking at the simplest, the select helper.…The syntax of the select helper…is that it takes a series of arguments,…the first of which is the object we're working with,…the second is the attribute on that object.…Then, we have a list of choices.…These are the choices that the user…is going to select between.…After that would come a hash of options,…and a hash of any HTML options.…
The kinds of options you would provide for options…would be options for the select tag.…I've given you a list of what those could be,…as well as their default values.…If you needed to specify the value that should be selected,…you could do that, but it's going to default…to the object attribute's current value.…If you wanted to include a blank choice,…so that they could make no choice,…or if you wanted to prompt them before they make a choice,…
- 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.