Refactor VideosController (#3806) [ci skip]

This commit is contained in:
Feruz Oripov 2019-08-27 03:59:31 +05:00 committed by Mac Siri
parent 45368132b0
commit ee498ad9ef

View file

@ -1,10 +1,9 @@
class VideosController < ApplicationController
after_action :verify_authorized, except: %i[index]
before_action :set_cache_control_headers, only: %i[index]
before_action :authorize_video, only: %i[new create]
def new
authorize :video
end
def new; end
def index
@video_articles = Article.published.
@ -16,7 +15,6 @@ class VideosController < ApplicationController
end
def create
authorize :video
@article = ArticleWithVideoCreationService.new(article_params, current_user).create!
redirect_to @article.path + "/edit"
@ -24,6 +22,10 @@ class VideosController < ApplicationController
private
def authorize_video
authorize :video
end
def article_params
params.require(:article).permit(:video)
end