Class: Hyrax::ContactFormController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Hyrax::ContactFormController
- Defined in:
- app/controllers/hyrax/contact_form_controller.rb
Instance Method Summary collapse
-
#after_deliver ⇒ Object
Override this method if you want to perform additional operations when a email is successfully sent, such as sending a confirmation response to the user.
- #create ⇒ Object
- #handle_create_exception(exception) ⇒ Object
- #new ⇒ Object
Instance Method Details
#after_deliver ⇒ Object
Override this method if you want to perform additional operations when a email is successfully sent, such as sending a confirmation response to the user.
37 |
# File 'app/controllers/hyrax/contact_form_controller.rb', line 37 def after_deliver; end |
#create ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/controllers/hyrax/contact_form_controller.rb', line 12 def create # not spam and a valid form if @contact_form.valid? ContactMailer.contact(@contact_form).deliver_now flash.now[:notice] = 'Thank you for your message!' after_deliver @contact_form = model_class.new else flash.now[:error] = 'Sorry, this message was not sent successfully. ' + @contact_form.errors..map(&:to_s).join(", ") end render :new rescue RuntimeError => exception handle_create_exception(exception) end |
#handle_create_exception(exception) ⇒ Object
28 29 30 31 32 |
# File 'app/controllers/hyrax/contact_form_controller.rb', line 28 def handle_create_exception(exception) logger.error("Contact form failed to send: #{exception.inspect}") flash.now[:error] = 'Sorry, this message was not delivered.' render :new end |
#new ⇒ Object
10 |
# File 'app/controllers/hyrax/contact_form_controller.rb', line 10 def new; end |