Creating a Sort Drop Down in Rails Using Form_With
--
We’re going to make a simple sort drop down with two options using form_with
, a rails form helper. Before we get started, what exactly is form_with
and why is it useful? Prior to Rails 5.1, we had only form_for
and form_tag
form helpers. form_for
is used to create and update model object attributes, and requires a model be passed in as an argument. A FormBuilder
object is yielded to the variable form
in the below code snippet, which allows us to generate fields associated with the attributes of our review
instance variable:
#…