Refactor VideosController (#3806) [ci skip]
This commit is contained in:
parent
45368132b0
commit
ee498ad9ef
1 changed files with 6 additions and 4 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue