Guest User

Untitled

a guest
Jun 19th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. class Emailer < ActionMailer::Base
  2.  
  3. def receive(mail)
  4. # ensure an author with that mail-address already exists.
  5. sender = mail.from
  6. author = Author.find_by_email(sender)
  7. raise "Couldn't find author with address #{sender}" if author.nil?
  8. # create a new post for this author (from received mail).
  9. Post.create!(
  10. :title => mail.subject,
  11. :body => mail.body,
  12. :author => author
  13. )
  14. puts 'posted Email as message'
  15. end
  16.  
  17. end
Add Comment
Please, Sign In to add comment