Simplify the skip_before_filter logic for UploadsController

This commit is contained in:
Robert Speicher 2015-04-20 13:40:17 -04:00
parent 926a814641
commit 10053b173d

View file

@ -1,11 +1,8 @@
class Projects::UploadsController < Projects::ApplicationController
layout 'project'
# We want to skip these filters for only the `show` action if `image?` is true,
# but `skip_before_filter` doesn't work with both `only` and `if`, so we accomplish the same like this.
skipped_filters = [:authenticate_user!, :reject_blocked!, :project, :repository]
skip_before_action *skipped_filters, only: [:show]
before_action *skipped_filters, only: [:show], unless: :image?
skip_before_action :authenticate_user!, :reject_blocked!, :project,
:repository, if: -> { action_name == 'show' && image? }
def create
link_to_file = ::Projects::UploadService.new(project, params[:file]).