Created
November 24, 2012 16:24
-
-
Save chyld/4140370 to your computer and use it in GitHub Desktop.
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
class QuestionsController < ApplicationController | |
before_filter :ensure_logged_in | |
def index | |
end | |
def show | |
end | |
def new | |
@question = Question.new | |
end | |
def create | |
question = Question.create(:question_text => params[:question][:question_text]) | |
@auth.questions << question | |
params[:question][:answers].each do |answer| | |
question.answers << Answer.create(:answer_text => answer[:text], :is_correct => answer[:correct].present?) | |
end | |
redirect_to questions_path | |
end | |
def edit | |
end | |
def update | |
end | |
def destroy | |
end | |
private | |
def ensure_logged_in | |
redirect_to root_path if @auth.nil? | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment