Flashing through #now on AJAX actions
This commit is contained in:
parent
14285b510c
commit
2a8f60be36
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user