Module: Hancock::Feedback::Controllers::Contacts
- Extended by:
- ActiveSupport::Concern
- Included in:
- Hancock::Feedback::ContactsController
- Defined in:
- lib/hancock/feedback/controllers/contacts.rb
Instance Method Summary collapse
- #cache_fields? ⇒ Boolean
- #cache_key ⇒ Object
- #create ⇒ Object
- #fields_partial ⇒ Object
- #hancock_feedback_update_captcha_path ⇒ Object
- #index ⇒ Object
- #is_cache_fields ⇒ Object
- #locals ⇒ Object
- #new ⇒ Object
- #recaptcha_options ⇒ Object
- #sent ⇒ Object
- #settings_scope ⇒ Object
- #update_captcha ⇒ Object
Instance Method Details
#cache_fields? ⇒ Boolean
75 76 77 |
# File 'lib/hancock/feedback/controllers/contacts.rb', line 75 def cache_fields? ['new', 'index'].include? action_name end |
#cache_key ⇒ Object
78 79 80 |
# File 'lib/hancock/feedback/controllers/contacts.rb', line 78 def cache_key 'hancock_feedback_contacts_fields'.freeze end |
#create ⇒ Object
26 27 28 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 |
# File 'lib/hancock/feedback/controllers/contacts.rb', line 26 def create = model.new() after_initialize if Hancock::Feedback.config.captcha if Hancock::Feedback.config.recaptcha_support if verify_recaptcha meth = :save else meth = :valid? @recaptcha_error = I18n.t('hancock.errors.feedback.recaptcha') end elsif Hancock::Feedback.config.simple_captcha_support meth = :save_with_captcha else meth = :save end else meth = :save end if .send(meth) and @recaptcha_error.blank? after_create if request.xhr? && process_ajax ajax_success else redirect_after_done end else render_contacts_error end end |
#fields_partial ⇒ Object
81 82 83 |
# File 'lib/hancock/feedback/controllers/contacts.rb', line 81 def fields_partial "hancock/feedback/contacts/#{(Hancock::Feedback.config.model_settings_support ? 'fields_with_settings' : 'fields')}".freeze end |
#hancock_feedback_update_captcha_path ⇒ Object
69 70 71 |
# File 'lib/hancock/feedback/controllers/contacts.rb', line 69 def hancock_feedback_update_captcha_path url_for(action: :update_captcha, time: Time.new.to_i, only_path: true) end |
#index ⇒ Object
14 15 16 17 18 |
# File 'lib/hancock/feedback/controllers/contacts.rb', line 14 def index = model.new after_initialize render locals: locals unless xhr_checker end |
#is_cache_fields ⇒ Object
72 73 74 |
# File 'lib/hancock/feedback/controllers/contacts.rb', line 72 def is_cache_fields cache_fields? end |
#locals ⇒ Object
96 97 98 99 100 101 102 103 104 |
# File 'lib/hancock/feedback/controllers/contacts.rb', line 96 def locals { is_cache_fields: is_cache_fields, cache_key: cache_key, fields_partial: fields_partial, settings_scope: settings_scope, recaptcha_options: } end |
#new ⇒ Object
20 21 22 23 24 |
# File 'lib/hancock/feedback/controllers/contacts.rb', line 20 def new = model.new after_initialize render locals: locals unless xhr_checker end |
#recaptcha_options ⇒ Object
93 94 95 |
# File 'lib/hancock/feedback/controllers/contacts.rb', line 93 def {} end |
#sent ⇒ Object
61 62 |
# File 'lib/hancock/feedback/controllers/contacts.rb', line 61 def sent end |
#settings_scope ⇒ Object
84 85 86 87 88 89 90 91 92 |
# File 'lib/hancock/feedback/controllers/contacts.rb', line 84 def settings_scope if Hancock::Feedback.config.model_settings_support model.settings elsif defined?(Settings) Settings.ns('feedback') else nil end end |
#update_captcha ⇒ Object
64 65 66 |
# File 'lib/hancock/feedback/controllers/contacts.rb', line 64 def update_captcha render layout: false end |