lib/enjoy/faq/controllers/questions.rb in enjoy_cms_faq-0.3.5 vs lib/enjoy/faq/controllers/questions.rb in enjoy_cms_faq-0.4.0.beta3
- old
+ new
@@ -27,11 +27,29 @@
end
def create
@question = question_class.new(question_params)
- _method = Enjoy::Faq.configuration.save_with_captcha ? :save_with_captcha : :save
+ 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
@@ -41,14 +59,14 @@
end
end
private
def question_params
- params[:question].permit(:question_text, :author_name, :author_email, :captcha, :captcha_key)
+ params[:enjoy_faq_question].permit(:question_text, :author_name, :author_email, :captcha, :captcha_key)
end
- def question_category_class
- Enjoy::Faq::QuestionCategory
+ def category_class
+ Enjoy::Faq::Category
end
def question_class
Enjoy::Faq::Question
end