I have the following code in a VIEW:
<select name="selected_budget_mode" class="" onchange="OnBudgetModeChanged(this)">
<option value="0"
<% if params[:current_budget_mode].to_i == 0 %>selected
<% end %>><%= show_budget_mode(0) %></option>
<option value="1"
<% if params[:current_budget_mode].to_i == 1 %>selected
<% end %>><%= show_budget_mode(1) %></option>
<option value="2"
<% if params[:current_budget_mode].to_i == 2 %>selected
<% end %>><%= show_budget_mode(2) %></option>
</select>
I am aware of the select_tag
and the options_for_select
form helpers, but that implies that I need to create a list with the options and then pass it to the options_for_select
.
The budgets_mode
are not dynamic. They don't come from calling a service or other function, there are only 3 modes.
What would be the best approach to simplify this code and make it as readable as possible?