Module: AskHelper

Defined in:
app/helpers/ask_helper.rb

Instance Method Summary collapse

Instance Method Details



3
4
5
6
7
8
9
10
# File 'app/helpers/ask_helper.rb', line 3

def link_to_add_fields(name, f, association)
  new_object = f.object.send(association).klass.new
  id = new_object.object_id
  fields = f.fields_for(association, new_object, child_index: id) do |builder|
    render("asker/"+association.to_s.singularize + "_fields", f: builder)
  end
  link_to(name, '#', class: "add_fields", data: {id: id, fields: fields.gsub("\n", "")})
end

#question_instructions(question) ⇒ Object



24
25
26
27
28
29
30
# File 'app/helpers/ask_helper.rb', line 24

def question_instructions(question)
  require 'rails_autolink/helpers'
  
  unless question.instructions.blank?
    (:span, auto_link(simple_format(question.instructions), :all, :target=>'_blank'), :class=>'instructions')
  end || ''
end

#question_label(question, builder = nil) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'app/helpers/ask_helper.rb', line 12

def question_label(question, builder=nil)
  if question.type.to_sym == :ChecklistQuestion
    h(question.name)
  else
    if builder
      builder.label(:answer, question.name)
    else
      label_tag(:answer, question.name)
    end
  end
end