class ArticlesController < ApplicationController
http_basic_authenticate_with name: "deba", password: "12345", except: [:index, :show]
def index
@articles = Article.all
end
def show
@article = Article.find(params[:id])
end
def new
@article = Article.new
end
def edit
@article = Article.find(params[:id])
end
def create
@article = Article.new(article_params)
@article.save
redirect_to @article
end
def update
@article = Article.find(params[:id])
if @article.update(article_params)
redirect_to @article
else
render 'edit'
end
end
def delete
@article = Article.find(params[:id])
@article.delete
redirect_to articles_path
end
private
def article_params
params.require(:article).permit(:title, :text)
end
end
I have tried to do like this, but it's not deleting the item. If i change the delete to destroy it is working fine but I have to change the default method name