Method: QuestionChain::Answers::InstanceMethods#create

Defined in:
lib/question_chain/answers.rb

#createObject



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/question_chain/answers.rb', line 48

def create
  @answer = build_resource
  enforce_permission
  @answer.user_id = current_user.id
  @answer.answer_params = params[:answer]
  @answer_params = params[:answer] # used for mustache templates
  @question = question_from_context
  @answer.question_id = @question.id
  @answer.result = get_answer(@question, @answer_params)
  set_answer_values_on_question!(@question, @answer_params)
  build_answer_errors!
  create! do |success, failure|
    success.html do
      flash[:notice] = create_success_flash_message
      @contexts << @answer
      redirect_to create_success_path
    end      
  end
end