Created
November 24, 2012 16:11
-
-
Save cgoodmac/4140325 to your computer and use it in GitHub Desktop.
Creating answers to questions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create | |
q = Question.create(params[:question]) | |
@auth.questions << q | |
binding.pry | |
params[:answers].each do |answer_hash| | |
a1 = Answer.create(answer_hash.to_param) | |
q.answers << a1 | |
end | |
redirect_to questions_path | |
end | |
Parameters: | |
{"utf8"=>"✓", | |
"authenticity_token"=>"8EGP4ThxdelvBt2s4AHcpVCBkdSsyPVOYj8a44X7QuQ=", | |
"question"=>{"question_text"=>"Hi"}, | |
"answers"=>[{"answer_text"=>"hello", | |
"is_correct"=>"on"}, | |
{"answer_text"=>"hey"}, | |
{"answer_text"=>""}, | |
{"answer_text"=>""}, | |
{"answer_text"=>""}], | |
"commit"=>"Create Question"} |
nilbus
commented
Nov 24, 2012
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment