1
0

Ingredient create/import redirect to proper page

This commit is contained in:
cryptogopher 2019-11-02 18:53:46 +01:00
parent 3689abb1dc
commit 05c79782f5

View File

@ -28,11 +28,10 @@ class IngredientsController < ApplicationController
end end
def create def create
# FIXME: redirect to :back?
@ingredient = @project.ingredients.new(ingredient_params) @ingredient = @project.ingredients.new(ingredient_params)
if @ingredient.save if @ingredient.save
flash[:notice] = 'Created new ingredient' flash[:notice] = 'Created new ingredient'
redirect_to project_ingredients_url(@project) redirect_to :back
else else
prepare_ingredients prepare_ingredients
@ingredient.nutrients.new(ingredient: @ingredient) if @ingredient.nutrients.empty? @ingredient.nutrients.new(ingredient: @ingredient) if @ingredient.nutrients.empty?
@ -67,7 +66,6 @@ class IngredientsController < ApplicationController
end end
def import def import
# FIXME: redirect to :back?
warnings = [] warnings = []
if params.has_key?(:file) if params.has_key?(:file)
@ -164,7 +162,7 @@ class IngredientsController < ApplicationController
warnings.unshift("Problems encountered during import - fix and try again:") warnings.unshift("Problems encountered during import - fix and try again:")
flash[:warning] = warnings.join("<br>").truncate(1024, omission: '...(and other)') flash[:warning] = warnings.join("<br>").truncate(1024, omission: '...(and other)')
end end
redirect_to project_ingredients_url(@project) redirect_to :back
end end
private private