Class: Rapidfire::AnswerGroupsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/rapidfire/answer_groups_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#authenticate_administrator!

Instance Method Details

#createObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/rapidfire/answer_groups_controller.rb', line 9

def create
  @answer_group_builder = AnswerGroupBuilder.new(answer_group_params)

  respond_to do |format|
    if @answer_group_builder.save
      format.html { redirect_to question_groups_path, notice: 'Survey was successfully created.' }
      format.json { render json: @answer_group_builder, status: :created, location: @answer_group_builder }
    else
      @answer_group_builder.errors.add(:base, "already answered")
      format.html { render "new" }
      format.json { render json: @answer_group_builder.errors, status: :unprocessable_entity }
    end
  end
end

#newObject



5
6
7
# File 'app/controllers/rapidfire/answer_groups_controller.rb', line 5

def new      
  @answer_group_builder = AnswerGroupBuilder.new(answer_group_params)
end