Class: MetadataPresenter::AnswersController

Inherits:
EngineController show all
Defined in:
app/controllers/metadata_presenter/answers_controller.rb

Instance Method Summary collapse

Methods inherited from EngineController

#allow_analytics?, #analytics_cookie_name, #analytics_tags_present?, #answered?, #back_link, #external_or_relative_link, #get_saved_progress, #increment_record_counter, #invalidate_record, #load_autocomplete_items, #maintenance_mode?, #reload_user_data, #save_form_progress, #show_cookie_confirmation?, #show_cookie_request?

Instance Method Details

#createObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/metadata_presenter/answers_controller.rb', line 5

def create
  @previous_answers = reload_user_data.deep_dup
  @page_answers = PageAnswers.new(page, answers_params, autocomplete_items(page.components))

  if params[:save_for_later].present?
    save_user_data
    # NOTE: if the user is on a file upload page, files will not be uploaded before redirection
    redirect_to save_path(page_slug: params[:page_slug]) and return
  end

  upload_files if upload?

  if @page_answers.validate_answers
    save_user_data # method signature
    redirect_to_next_page
  else
    render_validation_error
  end
end