Class: FormAnswersController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/form_answers_controller.rb

Instance Method Summary collapse

Instance Method Details

#attachmentsObject



33
34
35
36
# File 'app/controllers/form_answers_controller.rb', line 33

def attachments
  @form_answer = ActiveadminSelleoCms::FormAnswer.where(form_uuid: params[:form_uuid], form_question_id: params[:form_question_id]).first
  render partial: 'attachments'
end

#createObject



5
6
7
8
9
10
11
12
13
# File 'app/controllers/form_answers_controller.rb', line 5

def create
  params[:form_answer] ||= {}
  if answer = ActiveadminSelleoCms::FormAnswer.where(form_uuid: params[:form_answer][:form_uuid], dom_id: params[:form_answer][:dom_id]).first
    answer.update_attribute(:value, params[:form_answer][:value])
  else
    ActiveadminSelleoCms::FormAnswer.create(params[:form_answer])
  end
  render nothing: true
end

#editObject



19
20
21
# File 'app/controllers/form_answers_controller.rb', line 19

def edit
  @form_answer = ActiveadminSelleoCms::FormAnswer.find(params[:id])
end

#find_or_createObject



28
29
30
31
# File 'app/controllers/form_answers_controller.rb', line 28

def find_or_create
  @form_answer = ActiveadminSelleoCms::FormAnswer.find_or_create_by_form_uuid_and_dom_id_and_form_question_id(params[:form_uuid], params[:dom_id], params[:form_question_id])
  render action: :edit
end

#indexObject



15
16
17
# File 'app/controllers/form_answers_controller.rb', line 15

def index
  respond_with ActiveadminSelleoCms::FormAnswer.where(form_uuid: params[:form_uuid])
end

#updateObject



23
24
25
26
# File 'app/controllers/form_answers_controller.rb', line 23

def update
  @form_answer = ActiveadminSelleoCms::FormAnswer.find(params[:id])
  @form_answer.update_attributes(params[:form_answer])
end