My problem is that after i edit the article it reverts back to its old self
these are my pictures representing the steps I took while trying to edit:
after pressing the update button:
my code:
articles_controller:
class ArticlesController < ApplicationController
def index
@articles = Article.all
end
def new
@article = Article.new
end
def edit
@article = Article.find(params[:id])
end
def update
@article = Article.find(params[:id])
if @article.save
flash[:notice] = "article was updated"
redirect_to(@article)
else
render 'edit'
end
end
def create
@article = Article.new(article_params)
if @article.update(article_params)
flash[:notice] = "Article was submitted succsefully"
redirect_to (@article)
else
render 'new'
end
end
def show
@article = Article.find(params[:id])
end
private
def article_params
params.require(:article).permit(:title, :description)
end
end
ask me for more files i f it helps.
P.S. Please don't downvote this question
Aucun commentaire:
Enregistrer un commentaire