My form has:
<%= f.select(:amount, Payment::AMOUNT_VALUES, {:blank => false}) %>
My model has:
AMOUNT_VALUES = { '$ 0' => 0, '$ 1' => 1, '$ 2' => 2, '$ 5' => 5, '$ 10' => 10 }.
If user select $2 and submits form. The next time he goes back to the form, I need it only to display everything above $2 in the select box. Therefore, the options should be $5 and $10 only.
How can this be achieved?
I recently wrote some helper code that helped me rule out days of the week where a store had already posted business hours for. It shouldn’t be too hard to adapt to your specifications.
Updated: Added question-specific code and updated with a more-efficient reject block.
For your particular codebase, it’d probably look something like this:
I feel like there’s a better way of doing this, so I’ll update if I remember it.