app/controllers/user_trainings_controller.rb
# Verifies that a user_training id is provided as a parameter (except for an AJAX request, in which case it may be nil)
# and that the corresponding training is *visible* by the current user.
# Otherwise, it redirects to the home page.
# Assigns the @user_training instance when successful.
# (Assumes log-in has been enforced elsewhere.)
#
# == Controller Params:
# id: the user_training id to be processed by most of the methods (see before filter above)
#
Verifies that a user_training id is provided as a parameter (except for an AJAX request, in which case it may be nil)
and that the corresponding training is *visible* by the current user.
Otherwise, it redirects to the home page.
Assigns the @user_training instance when successful.
(Assumes log-in has been enforced elsewhere.)

Controller Params:
id: the user_training id to be processed by most of the methods
Verifies that a user_training id is provided as a parameter ( except for an AJAX request in which case it may be nil ) and that the corresponding training is * visible * by the current user . Otherwise it redirects to the home page . Assigns the @user_training instance when successful . ( Assumes log - in has been enforced elsewhere . ) Controller Params : id : the user_training id to be processed by most of the methods
def verify_visibility
    set_user_training
    if UserTrainingAccessibility.new( current_user, @user_training ).is_visible ||
       ( request.xhr? && @user_training.nil? )
      return
    else
      if request.xhr?
        render( status: 406, json: { success: false, message: I18n.t(:invalid_action_request) } ) and return
      else
        flash[:error] = I18n.t(:invalid_action_request)
        redirect_to( user_trainings_path() ) and return
      end
    end
  end
def verify_visibility set_user_training if UserTrainingAccessibility . new ( current_user , @user_training ) . is_visible || ( request . xhr? && @user_training . nil? ) return else if request . xhr? render ( status : 406 , json : { success : false , message : I18n . t ( :invalid_action_request ) } ) and return else flash [ :error ] = I18n . t ( :invalid_action_request ) redirect_to ( user_trainings_path ( ) ) and return end end end
Verifies that a user_training id is provided as a parameter (except for an AJAX request, in which case it may be nil)
and that the corresponding training is *visible* by the current user.
Verifies that a user_training id is provided as a parameter ( except for an AJAX request in which case it may be nil ) and that the corresponding training is * visible * by the current user .