app/controllers/user_trainings_controller.rb
# Prepares the selected training data for a PDF print-out.
# Supports the creation of a single file contaning a single Training header only
# (including all its detail rows).
#
# == Params:
#
# - <tt>:id</tt> =>
#   The id of the Training header; all its details will be retrieved also.
#
Prepares the selected training data for a PDF print-out.
Supports the creation of a single file contaning a single Training header only
(including all its detail rows).



:id =>
The id of the Training header; all its details will be retrieved also.
Prepares the selected training data for a PDF print - out . Supports the creation of a single file contaning a single Training header only ( including all its detail rows ) . : id = > The id of the Training header ; all its details will be retrieved also .
def printout()
    user_training_rows = @user_training.user_training_rows
        .includes(:exercise, :training_step_type)
        .sort_by_part_order
        .all
    if user_training_rows.size < 1
      flash[:error] = I18n.t(:no_detail_to_process)
      redirect_to( user_trainings_path() ) and return
    end
    title = I18n.t('trainings.show_title').gsub( "{TRAINING_TITLE}", @user_training.description )
    base_filename = "#{I18n.t('trainings.training')}_#{@user_training.description}"
    filename = create_unique_filename( base_filename ) + '.pdf'
    options = {
      report_title:       title,
      meta_info_subject:  'training model printout',
      meta_info_keywords: "Goggles, #{base_filename}",
      header_row:         TrainingDecorator.decorate( @user_training ),
      detail_rows:        TrainingRowDecorator.decorate_collection( user_training_rows )
    }
    send_data(                                      
        TrainingPrintoutLayout.render( options ),
        type: 'application/pdf',
        filename: filename
    )
  end
def printout ( ) user_training_rows = @user_training . user_training_rows . includes ( :exercise , :training_step_type ) . sort_by_part_order . all if user_training_rows . size < 1 flash [ :error ] = I18n . t ( :no_detail_to_process ) redirect_to ( user_trainings_path ( ) ) and return end title = I18n . t ( 'trainings.show_title' ) . gsub ( "{TRAINING_TITLE}" , @user_training . description ) base_filename = "#{I18n.t('trainings.training')}_#{@user_training.description}" filename = create_unique_filename ( base_filename ) + '.pdf' options = { report_title : title , meta_info_subject : 'training model printout' , meta_info_keywords : "Goggles, #{base_filename}" , header_row : TrainingDecorator . decorate ( @user_training ) , detail_rows : TrainingRowDecorator . decorate_collection ( user_training_rows ) } send_data ( TrainingPrintoutLayout . render ( options ) , type : 'application/pdf' , filename : filename ) end
Prepares the selected training data for a PDF print-out.
Prepares the selected training data for a PDF print - out .
# == OPTIONS setup + RENDERING phase == # == Render layout & send data: