In an existing codebase, one attribute of the discount model is discount_type. Since there are only 2 types of discounts (percentage and cash) used in this system, they are hardcoded as percentage or cash throughout the system, there is no discount_types table or anything to map to.
In the form, there is the following code:
=form_for @discount do |f|
...
=f.select :discount_type, options_for_select(["percentage", "cash"])
...
This works great for new discounts, but when pulling up the form to edit a discount, percentage is always selected, no matter what the discount object’s discount_type is. How do we get the form to default to the discount_type of the object being edited?
Wouldn’t simple
be enough?