Class: Notifications
- Inherits:
-
ActionMailer::Base
- Object
- ActionMailer::Base
- Notifications
- Defined in:
- app/mailers/notifications.rb
Overview
Use this mailer to send notifications eg for newly created pages, sign ups and so on.
Instance Method Summary (collapse)
-
- (Object) account_confirmed(user)
Inform the admin if a user confirms an account.
-
- (Object) cancel_account(user_info)
Inform the admin when a user cancel an account.
-
- (Object) invite_user(invitation, subject, message)
Invite User arg[0] = Invitation-id.
-
- (Object) new_comment_created(recipient, title, from_mail, from_name, comment, link_to_commentable)
Infrom owner of commentable, and admin when a comment was posted arg[0] = recipient, arg[1] = commentable.title, arg[2] = email, arg[3] = name, arg[4] = comment.
-
- (Object) new_posting_created(blog_id, posting_id)
Inform admin when new postings created.
-
- (Object) sign_up(new_user)
When a new user signed up, inform the adminstrator.
Instance Method Details
- (Object) account_confirmed(user)
Inform the admin if a user confirms an account
25 26 27 28 29 |
# File 'app/mailers/notifications.rb', line 25 def account_confirmed(user) @notify_subject = "USER CONFIRMED ACCOUNT AT #{APPLICATION_CONFIG['name']}" @user = user mail( :to => APPLICATION_CONFIG['admin_notification_address'], :subject => @notify_subject) end |
- (Object) cancel_account(user_info)
Inform the admin when a user cancel an account.
18 19 20 21 22 |
# File 'app/mailers/notifications.rb', line 18 def cancel_account(user_info) @user_info = user_info @notify_subject = "USER CANCELED ACCOUNT AT #{APPLICATION_CONFIG['name']}" mail( :to => APPLICATION_CONFIG['admin_notification_address'], :subject => @notify_subject) end |
- (Object) invite_user(invitation, subject, message)
Invite User arg[0] = Invitation-id
90 91 92 93 94 95 96 97 98 |
# File 'app/mailers/notifications.rb', line 90 def invite_user(invitation,subject,) @subject = subject @sign_up_url = new_user_registration_url(:token => invitation.token) @invitation = invitation @message = mail( :from => invitation.user.email, :to => invitation.email, :subject => subject ) end |
- (Object) new_comment_created(recipient, title, from_mail, from_name, comment, link_to_commentable)
Infrom owner of commentable, and admin when a comment was posted arg[0] = recipient, arg[1] = commentable.title, arg[2] = email, arg[3] = name, arg[4] = comment
76 77 78 79 80 81 82 83 84 85 86 |
# File 'app/mailers/notifications.rb', line 76 def new_comment_created(recipient,title,from_mail,from_name,comment, link_to_commentable) @notify_subject = "Your entry '#{title}', was commented by #{from_name}" @comment = comment @from_name = from_name @from_mail = from_mail @link_to_commentable = link_to_commentable mail( :from => from_mail, :to => [APPLICATION_CONFIG['admin_notification_address'],recipient].uniq, :subjcect => @notify_subject ) end |
- (Object) new_posting_created(blog_id, posting_id)
Inform admin when new postings created
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 60 61 62 63 64 65 66 67 68 |
# File 'app/mailers/notifications.rb', line 32 def new_posting_created(blog_id,posting_id) blog = Blog.find(blog_id) posting = blog.postings.find(posting_id) @blogtitle= blog.title @title = posting.title @username = posting.user.name @content = posting.render_for_html(body).html_safe @url = blog_posting_url(blog,posting) @notify_subject = "A NEW POSTING WAS CREATED AT #{APPLICATION_CONFIG['name']}" begin # Attach cover picture if posting.cover_picture_exists? if File.exist?(filename=posting.cover_picture.path) [File::basename(filename)] = File.read(filename) end end # TODO: The following code doesn't work. Either there is a bug somewhere # TODO: in CBA or in Rails::Mail. Only the cover-pic arrives. # TODO: Check if it's possible to attach more files with Rails Mail - it should! # Attach attachments posting..each do |att| path = att.file.path.gsub(/\?.*$/,"") file = File::basename(path) if File.exist?(path) [file] = File.read(path) end end rescue => e msg = "<br/><br/>*** ERROR ATTACHING FILE #{e.to_s} **** #{__FILE__}:#{__LINE__}" @content += msg.html_safe puts msg end mail( :to => APPLICATION_CONFIG['admin_notification_address'], :subject => @notify_subject) end |
- (Object) sign_up(new_user)
When a new user signed up, inform the adminstrator
11 12 13 14 15 |
# File 'app/mailers/notifications.rb', line 11 def sign_up(new_user) @user = new_user @notify_subject = "NEW SIGN UP AT #{APPLICATION_CONFIG['name']}" mail( :to => APPLICATION_CONFIG['admin_notification_address'], :subject => @notify_subject) end |