Skip to content
This repository was archived by the owner on Aug 13, 2021. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions app/controllers/articles_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class ArticlesController < ApplicationController
before_action :set_article, only: [:show, :edit, :update]
# before_filter :authenticate_user!
respond_to :html

Expand All @@ -8,7 +9,6 @@ def index
end

def show
@article = Article.find(params[:id])
@parent = @article
@comment = Comment.new
end
Expand All @@ -31,11 +31,9 @@ def create
end

def edit
@article = Article.find(params[:id])
end

def update
@article = Article.find(params[:id])
if @article.update_attributes(article_params)
redirect_to article_path, notice: 'The article has been successfully updated.'
else
Expand All @@ -44,8 +42,11 @@ def update
end

private
def set_acticle
@article = Article.find(params[:id])
end

def article_params
params.require(:article).permit(:title, :content, :date, :description, :user_id, :cover)
end
def article_params
params.require(:article).permit(:title, :content, :date, :description, :user_id, :cover)
end
end