From the course: Ruby on Rails 5 Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Form options helpers

Form options helpers - Ruby on Rails Tutorial

From the course: Ruby on Rails 5 Essential Training

Start my 1-month free trial

Form options helpers

- [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…

Contents