diff --git a/app/controllers/foods_controller.rb b/app/controllers/foods_controller.rb index a3a184d..e96bf55 100644 --- a/app/controllers/foods_controller.rb +++ b/app/controllers/foods_controller.rb @@ -26,7 +26,7 @@ class FoodsController < ApplicationController def create @food = @project.foods.new(food_params) if @food.save - flash[:notice] = 'Created new food' + flash.now[:notice] = 'Created new food' prepare_items else @food.nutrients.new(unit: @food.ref_unit) if @food.nutrients.empty? @@ -39,7 +39,7 @@ class FoodsController < ApplicationController def update if @food.update(food_params) - flash[:notice] = 'Updated food' + flash.now[:notice] = 'Updated food' prepare_items render :index else diff --git a/app/controllers/meals_controller.rb b/app/controllers/meals_controller.rb index 0681168..b29a40c 100644 --- a/app/controllers/meals_controller.rb +++ b/app/controllers/meals_controller.rb @@ -24,7 +24,7 @@ class MealsController < ApplicationController def create @meal = @project.meals.new(meal_params) if @meal.save - flash[:notice] = 'Created new meal' + flash.now[:notice] = 'Created new meal' prepare_meals else @meal.ingredients.new if @meal.ingredients.empty? @@ -37,7 +37,7 @@ class MealsController < ApplicationController def update if @meal.update(meal_params) - flash[:notice] = 'Updated meal' + flash.now[:notice] = 'Updated meal' prepare_meals render :index else @@ -46,7 +46,7 @@ class MealsController < ApplicationController end def destroy - flash[:notice] = 'Deleted meal' if @meal.destroy + flash.now[:notice] = 'Deleted meal' if @meal.destroy end def edit_notes diff --git a/app/controllers/measurements_controller.rb b/app/controllers/measurements_controller.rb index 8fdb316..56da5f0 100644 --- a/app/controllers/measurements_controller.rb +++ b/app/controllers/measurements_controller.rb @@ -42,7 +42,7 @@ class MeasurementsController < ApplicationController routine.quantities << @measurement.readouts.map(&:quantity).first(6) end - flash[:notice] = 'Created new measurement' + flash.now[:notice] = 'Created new measurement' prepare_items else @measurement.readouts.new if @measurement.readouts.empty? @@ -56,10 +56,11 @@ class MeasurementsController < ApplicationController def update update_routine_from_params if @measurement.update(measurement_params) - flash[:notice] = 'Updated measurement' if @measurement.routine.previous_changes.has_key?(:name) && @routine + flash[:notice] = 'Updated measurement' render js: "window.location.pathname='#{readouts_measurement_routine_path(@routine)}'" else + flash.now[:notice] = 'Updated measurement' prepare_items render :index end @@ -70,7 +71,7 @@ class MeasurementsController < ApplicationController def destroy if @measurement.destroy - flash[:notice] = 'Deleted measurement' + flash.now[:notice] = 'Deleted measurement' end end diff --git a/app/controllers/quantities_controller.rb b/app/controllers/quantities_controller.rb index 96c55ce..ae4e72f 100644 --- a/app/controllers/quantities_controller.rb +++ b/app/controllers/quantities_controller.rb @@ -24,7 +24,7 @@ class QuantitiesController < ApplicationController def create @quantity = @project.quantities.new(quantity_params) if @quantity.save - flash[:notice] = 'Created new quantity' + flash.now[:notice] = 'Created new quantity' prepare_quantities else render :new @@ -37,7 +37,7 @@ class QuantitiesController < ApplicationController def update if @quantity.update(quantity_params) - flash[:notice] = 'Updated quantity' + flash.now[:notice] = 'Updated quantity' prepare_quantities render :index else @@ -48,7 +48,7 @@ class QuantitiesController < ApplicationController def destroy @quantity_tree = @quantity.self_and_descendants.load if @quantity.destroy - flash[:notice] = 'Deleted quantity' + flash.now[:notice] = 'Deleted quantity' end end @@ -95,7 +95,7 @@ class QuantitiesController < ApplicationController @parent_quantity = @quantity.parent render :new_child end - flash[:notice] = 'Created new quantity' + flash.now[:notice] = 'Created new quantity' prepare_quantities end diff --git a/app/controllers/targets_controller.rb b/app/controllers/targets_controller.rb index 591fd9c..2b3ef17 100644 --- a/app/controllers/targets_controller.rb +++ b/app/controllers/targets_controller.rb @@ -37,7 +37,7 @@ class TargetsController < ApplicationController # :save only after build, to re-display values in case records are invalid if @goal.save && Target.transaction { @targets.all?(&:save) } - flash[:notice] = 'Created new target(s)' + flash.now[:notice] = 'Created new target(s)' # create view should only refresh targets belonging to @goal # e.g. by rendering to div#goal-id-targets prepare_targets