1
0

Added MealsController#toggle_exposure

This commit is contained in:
cryptogopher
2020-04-25 15:52:35 +02:00
parent a4781b4fcd
commit ab8ed92929
5 changed files with 24 additions and 10 deletions

View File

@@ -6,6 +6,7 @@ class MealsController < ApplicationController
include Concerns::Finders
before_action :find_project_by_project_id, only: [:index, :new, :create]
before_action :find_quantity_by_quantity_id, only: [:toggle_exposure]
before_action :find_meal, only: [:edit, :update, :destroy, :edit_notes, :update_notes,
:toggle_eaten]
before_action :authorize
@@ -59,6 +60,11 @@ class MealsController < ApplicationController
prepare_meals
end
def toggle_exposure
@project.meal_exposures.toggle!(@quantity)
prepare_meals
end
private
def meal_params

View File

@@ -8,7 +8,8 @@
<table>
<tr>
<td style="width:100%"></td>
<td><%= select_tag 'quantity_id', toggle_column_options %></td>
<td><%= select_tag 'quantity_id',
toggle_exposure_options(@project.meal_exposures, :diet) %></td>
<td><%= submit_tag l(:button_add) %></td>
</tr>
</table>