Changes and improvements to the process.
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
class ApplicationController < ActionController::Base
|
||||
|
||||
end
|
||||
@@ -0,0 +1,29 @@
|
||||
class ArticlesController < ApplicationController
|
||||
def index
|
||||
@articles = Article.all
|
||||
end
|
||||
|
||||
def show
|
||||
@article = Article.find(params[:id])
|
||||
end
|
||||
|
||||
def new
|
||||
@article = Article.new
|
||||
end
|
||||
|
||||
def create
|
||||
@article = Article.new(article_params)
|
||||
|
||||
if @article.save
|
||||
redirect_to @article
|
||||
else
|
||||
render 'new'
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def article_params
|
||||
params.require(:article).permit(:title, :text)
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user