Sha256: 7d42e1bd50e028c1c7a2511be8d6be04f036ab1ebe2aefcb5afefd8185e5324e

Contents?: true

Size: 807 Bytes

Versions: 4

Compression:

Stored size: 807 Bytes

Contents

module Refinery
  module Contacts
    class MailMessagesController < ::ApplicationController

      def deliver
        @mail_message = MailMessage.new(params[:mail_message])


        if @mail_message.valid? && verify_recaptcha(:model => @mail_message)
          mail = Refinery::Contacts::Mail.select("mail").find(@mail_message.recipient_id)
          @mail_message.recipient_mail = mail[:mail].to_s

          ContactMailer.contact_form(@mail_message).deliver


          flash[:notice] = t('refinery.contacts.contacts.flash.successfull_delivery')
        else
          flash[:mail_message] = @mail_message # send back to form data from filled fields. this is not very good way, but better than monkey-patch Page's controller, I think
        end

        redirect_to :back
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
refinerycms-contacts-0.2.0 app/controllers/refinery/contacts/mail_messages_controller.rb
refinerycms-contacts-0.1.2 app/controllers/refinery/contacts/mail_messages_controller.rb
refinerycms-contacts-0.1.1 app/controllers/refinery/contacts/mail_messages_controller.rb
refinerycms-contacts-0.1.0 app/controllers/refinery/contacts/mail_messages_controller.rb