app/controllers/user_trainings_controller.rb
# Create a new UserTrainingStory using the specified UserTraining id (POST only).
#
# == Params:
#
# - <tt>:id</tt> =>
#   The id of the UserTraining; all its details will be retrieved also.
#
Create a new UserTrainingStory using the specified UserTraining id (POST only).
Params.

:id =>
The id of the UserTraining; all its details will be retrieved also.
Create a new UserTrainingStory using the specified UserTraining id ( POST only ) . Params . : id = > The id of the UserTraining ; all its details will be retrieved also .
def create_user_story
    if request.post?
      new_user_training_story = UserTrainingStory.new()
      new_user_training_story.user_id = current_user.id
      new_user_training_story.total_training_time = @user_training.esteemed_total_seconds
      new_user_training_story.user_training_id = @user_training.id
      new_user_training_story.swimmer_level_type_id = current_user.get_preferred_swimmer_level_id
      new_user_training_story.swam_date = Date.today
      begin
        if new_user_training_story.save!
          flash[:info] = I18n.t('user_training_stories.story_created')
          redirect_to( edit_user_training_story_path(new_user_training_story) ) and return
        end
      rescue
        flash[:error] = "#{I18n.t('something_went_wrong')}"
        redirect_to( user_trainings_path() ) and return
      end
    else
      flash[:error] = I18n.t(:invalid_action_request)
      redirect_to( user_trainings_path() ) and return
    end
  end
def create_user_story if request . post? new_user_training_story = UserTrainingStory . new ( ) new_user_training_story . user_id = current_user . id new_user_training_story . total_training_time = @user_training . esteemed_total_seconds new_user_training_story . user_training_id = @user_training . id new_user_training_story . swimmer_level_type_id = current_user . get_preferred_swimmer_level_id new_user_training_story . swam_date = Date . today begin if new_user_training_story . save! flash [ :info ] = I18n . t ( 'user_training_stories.story_created' ) redirect_to ( edit_user_training_story_path ( new_user_training_story ) ) and return end rescue flash [ :error ] = "#{I18n.t('something_went_wrong')}" redirect_to ( user_trainings_path ( ) ) and return end else flash [ :error ] = I18n . t ( :invalid_action_request ) redirect_to ( user_trainings_path ( ) ) and return end end
Create a new UserTrainingStory using the specified UserTraining id (POST only).
Create a new UserTrainingStory using the specified UserTraining id ( POST only ) .
# TODO get swimming_pool_id from a previously saved, (same-) user story, if available