Module: Enjoy::Faq::Controllers::Questions

Extended by:
ActiveSupport::Concern
Included in:
QuestionsController
Defined in:
lib/enjoy/faq/controllers/questions.rb

Instance Method Summary collapse

Instance Method Details

#createObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/enjoy/faq/controllers/questions.rb', line 29

def create
  @question = question_class.new(question_params)

  if Enjoy::Faq.config.captcha
    if Enjoy::Faq.config.recaptcha_support
      if verify_recaptcha
        meth = :save
      else
        meth = :valid?
        @recaptcha_error = I18n.t('enjoy.errors.faq.recaptcha')
      end

    elsif Enjoy::Faq.config.simple_captcha_support
      meth = :save_with_captcha

    else
      meth = :save
    end
  else
    meth = :save
  end

  if @question.send(_method)
    @message = "Успешно создано все"
  else
    @message = "Косяки есть"
  end

  if request.xhr?
    render layout: false
  end
end

#indexObject



6
7
8
9
# File 'lib/enjoy/faq/controllers/questions.rb', line 6

def index
  @questions = question_class.enabled.sorted.to_a
  # index_crumbs
end

#page_titleObject



21
22
23
24
25
26
27
# File 'lib/enjoy/faq/controllers/questions.rb', line 21

def page_title
  if @question
    @question.page_title
  else
    super
  end
end

#showObject



11
12
13
14
15
16
17
18
19
# File 'lib/enjoy/faq/controllers/questions.rb', line 11

def show
  @question = question_class.enabled.find(params[:id])
  if !@question.text_slug.blank? and @question.text_slug != params[:id]
    redirect_to @question, status_code: 301
    return
  end
  @parent_seo_page = find_seo_page(question_categories_path) if @seo_page.blank?
  # item_crumbs
end