Created
October 23, 2010 09:12
-
-
Save maricris-sn/641979 to your computer and use it in GitHub Desktop.
As seen in: http://coderkitty.sweetperceptions.com/2009/3/9/extending-database_form-to-send-emails-via-mailer-extension
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## vendor/extensions/database_form/app/models/database_form_page.rb | |
# Save form data | |
def save_form | |
form_response = FormResponse.new(:name => form_name) | |
form_response.content = form_data | |
if !form_response.save | |
@form_error = "Error encountered while trying to submit form. #{$!}" | |
false | |
else | |
send_static_email(form_data) unless self.parts.find_by_name('mailer').blank? | |
true | |
end | |
end | |
def send_static_email(form_data) | |
mailer_config = YAML::load(self.parts.find_by_name('mailer').content).symbolize_keys | |
mail = Mail.new(self, mailer_config, form_data) | |
mail.send | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment