Skip to content

Instantly share code, notes, and snippets.

@descovi
Created January 23, 2023 16:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save descovi/6951dead5d6c4bc3bc719277a7a01b13 to your computer and use it in GitHub Desktop.
Save descovi/6951dead5d6c4bc3bc719277a7a01b13 to your computer and use it in GitHub Desktop.
class ArticlesController < ApplicationController
def create
@article = Article.create article_params
if @article.save
redirect_to article_path(@article)
else
render :new
end
end
def delete
@article = Article.find params[:id]
@article.delete
redirect_to articles_path
end
def article_params
params.require(:article).permit(:title, :content)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment