The code in my select duration is very large, now I learned a way to simplify the code:

To simplify my selector of duration and then to not have to write all that I have defined a constant DURATION as a hash.

This I am defining it in my model Output.

For this to work I delete all my options selector and replace it with the following code:

duration_output

What I am saying here is that to edit my outputs (line 32 to 38)
Iā€™m calling to the constant DURATION and will run each method (that I need to pass through the entire array). If the duration of my output is the same as the duration that of that option, it is shown as selected.

To create a new Output, we use the same code, except that we will remove the condition, since for this case we do not need it.

duration_output1