Destroy element category in ruby on rails

RUBY ON RAIL

Posted on 2016-11-30 22:39:34


you need read article related to management categories before implement function destroy category. It is better for you.

Management categories in ruby on rails

 

Edit category in ruby on rails

1. In controller

def destroy

    Category.find(params[:id]).destroy

    flash[:success] = "Category deleted"

    redirect_to categories_url

end

2. In view

= link_to "Delete", user, method: :delete, data: { confirm: "You sure?" }

 

This is link to delete a category with confirm "You sure?" before delete record.


This is result