Skip to content

Instantly share code, notes, and snippets.

@sirmxanot
Created February 29, 2012 15:50
Show Gist options
  • Save sirmxanot/1941899 to your computer and use it in GitHub Desktop.
Save sirmxanot/1941899 to your computer and use it in GitHub Desktop.
def destroy
@expense = Expense.find(params[:id])
if @expense.user_id == current_user.id
@expense.destroy
flash[:success] = "You have successfully deleted the expense."
else
flash[:error] = "You can't delete expenses that you didn't create."
end
respond_to do |format|
format.html { redirect_to expenses_url }
format.json { head :ok }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment