im working in a project writen in ruby on rails and im currently using the active admin gem for its content manager system of my site im just wondering how active admin is using the delete action im trying to overide it but i my code doesent work, i think we are having a problem in how to get the specific line to be destroy
def destroy
@menu = Menu.find(params[:menu_recipe][:menu_id])
@menu_recipe = @menu.menu_recipes.find(params[:id])
@menu_recipe.remove_recipe
@menu_recipe.destroy
redirect_to @reservation, :notice => "recipe destroyed"
end
it comes with a error of
undefined method `[]' for nil:NilClass
Probably
params[:menu_recipe]is not set. Try puttingparams[:menu_recipe] ||= {}at the beginning.But why is it that you’re finding through the
Menu, anyway? Can’t you just do ‘MenuRecipe.find(params[:id])’?