diff --git a/app/controllers/federal_tax_brackets_controller.rb b/app/controllers/federal_tax_brackets_controller.rb index 88426d5..08664de 100644 --- a/app/controllers/federal_tax_brackets_controller.rb +++ b/app/controllers/federal_tax_brackets_controller.rb @@ -61,6 +61,10 @@ def destroy end end + def federal_tax_filing_status_select + @federal_tax_bracket = FederalTaxBracket.find(params[:fed_tax_table]) + end + private # Use callbacks to share common setup or constraints between actions. diff --git a/app/views/dashboard/index.html.erb b/app/views/dashboard/index.html.erb index e24865a..fa8b27e 100644 --- a/app/views/dashboard/index.html.erb +++ b/app/views/dashboard/index.html.erb @@ -36,27 +36,21 @@ - <%= form_with model: @federal_tax_table_type, local: true do |form| %> -
-
- <%= form.label :single %> - <%= form.radio_button :single, FederalTaxTableType.find_by(filing_status: 'single').id, required: true %> +
+ Filing status + <%= form_with url: federal_tax_filing_status_select_path, local: true do |form| %> +
+ <% FederalTaxTableType.all.each do |table| %> +
+ <%= form.radio_button :fed_tax_table, table.id, onchange: "this.form.requestSubmit()" %> + <%= form.label :fed_tax_table, table.filing_status.humanize.capitalize %> + + +
+ <% end %>
-
- <%= form.label :married_filing_jointly %> - <%= form.radio_button :married_filing_jointly, FederalTaxTableType.find_by(filing_status: 'married_filing_jointly').id %> -
-
- <%= form.label :married_filing_separately %> - <%= form.radio_button :married_filing_separately, FederalTaxTableType.find_by(filing_status: 'married_filing_separately').id %> -
- -
- <%= form.label :head_of_household %> - <%= form.radio_button :head_of_household, FederalTaxTableType.find_by(filing_status: 'head_of_household') %> -
-
- <% end %> + <% end %> +
<%= render partial: "budget/salary_budget", diff --git a/config/routes.rb b/config/routes.rb index 0fca9f2..eaee8c7 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -5,4 +5,5 @@ root "dashboard#index" resources :incomes post "/income_switch", to: "incomes#income_switch" + post '/federal_tax_filing_status_select', to: 'federal_tax_brackets#federal_tax_filing_status_select' end