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 putting params[: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])'?
Menu
, the line I put should go at the very beginning of the action. Note that you'll also have to be careful before doing Menu.find(params[:menu_recipe][:menu_id])
since if the params[:menu_recipe][:menu_id]
is nil, the find will raise an exception - tsherif 2012-04-05 15:33
params[:menu_recipe] ||= {}
im new in ruby on rails sorry - Led 2012-04-05 15:25