i cant wrap my head around this problem, need some help :D.
I have one Model name "Recipe", defined Rest and so on... but i wanted to add 1 custom method to the 7 actions of REST. In this case, after save a Recipe it should redirect_to the createingredient action (with the :id in the params hash)
In the createingredient action, a variable should be define (@recipe) by the params[:id]. The prams[:id] exits, but somehow the view could not access to the @recipe
def new
@recipe = Recipe.new
end
def create
@recipe = Recipe.new(params_value)
if @recipe.save
redirect_to action: "newingredient",id: @recipe.id, notice: "Recipe succesfully created, time to add Ingredients"
else
render "new"
end
end
the custommethode
def newingredient
@recipe = Recipe.find(params[:id]) end
Thank you very much !
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…