app/controllers/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()
    training_rows = @training.training_rows.includes(:exercise, :training_step_type).sort_by_part_order.all
    if training_rows.size < 1
      flash[:error] = I18n.t(:no_detail_to_process)
      redirect_to( trainings_path() ) and return
    end
    title = I18n.t('trainings.show_title').gsub( "{TRAINING_TITLE}", @training.title )
    base_filename = "#{I18n.t('trainings.training')}_#{@training.title}"
    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( @training ),
      :detail_rows          => TrainingRowDecorator.decorate_collection( training_rows )
    }
    send_data(                                      
        TrainingPrintoutLayout.render( options ),
        :type => 'application/pdf',
        :filename => filename
    )
  end
def printout ( ) training_rows = @training . training_rows . includes ( :exercise , :training_step_type ) . sort_by_part_order . all if training_rows . size < 1 flash [ :error ] = I18n . t ( :no_detail_to_process ) redirect_to ( trainings_path ( ) ) and return end title = I18n . t ( 'trainings.show_title' ) . gsub ( "{TRAINING_TITLE}" , @training . title ) base_filename = "#{I18n.t('trainings.training')}_#{@training.title}" 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 ( @training ) , :detail_rows => TrainingRowDecorator . decorate_collection ( 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: