module Enjoy::Faq::Controllers::Questions

Public Instance Methods

create() click to toggle source
# 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
index() click to toggle source
# File lib/enjoy/faq/controllers/questions.rb, line 6
def index
  @questions = question_class.enabled.sorted.to_a
  # index_crumbs
end
page_title() click to toggle source
Calls superclass method
# File lib/enjoy/faq/controllers/questions.rb, line 21
def page_title
  if @question
    @question.page_title
  else
    super
  end
end
show() click to toggle source
# 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

Private Instance Methods

category_class() click to toggle source
# File lib/enjoy/faq/controllers/questions.rb, line 67
def category_class
  Enjoy::Faq::Category
end
question_class() click to toggle source
# File lib/enjoy/faq/controllers/questions.rb, line 70
def question_class
  Enjoy::Faq::Question
end
question_params() click to toggle source
# File lib/enjoy/faq/controllers/questions.rb, line 63
def question_params
  params[:enjoy_faq_question].permit(:question_text, :author_name, :author_email, :captcha, :captcha_key)
end