Skip to content

Instantly share code, notes, and snippets.

@micedreams
Created December 18, 2021 08:35
Show Gist options
  • Save micedreams/0c6686578ecda131ec8ad20c8047f7d3 to your computer and use it in GitHub Desktop.
Save micedreams/0c6686578ecda131ec8ad20c8047f7d3 to your computer and use it in GitHub Desktop.
def create
@question = Question.new(question_params)
respond_to do |format|
if @question.save
format.html { redirect_to @question, notice: "Question was successfully created." }
format.json { render :show, status: :created, location: @question }
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @question.errors, status: :unprocessable_entity }
end
end
end
#create method from quiz controller
def create
@quiz = Quiz.new(quiz_params)
respond_to do |format|
if @quiz.save
# should take to add new questiom
format.html { redirect_to new_quiz_question_path(@quiz), notice: "Quiz was successfully created." }
format.json { render :show, status: :created, location: @quiz }
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @quiz.errors, status: :unprocessable_entity }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment