Created
March 9, 2012 13:26
-
-
Save stepantubanov/2006496 to your computer and use it in GitHub Desktop.
Revisions
-
stepantubanov revised this gist
May 12, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -26,7 +26,7 @@ module Email module Invitations class Base def subject "Join our cool website" # Options: return I18n key "join_website", or the value h.t("....join_website") end def template -
stepantubanov revised this gist
Mar 19, 2012 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -70,5 +70,4 @@ module Views # And use them invitation = "Decorators::Email::#{invitation.class.name}".constantize.new mail(to: invitation.recipient_email, subject: invitation.subject, template_name: invitation.template) -
stepantubanov revised this gist
Mar 9, 2012 . 1 changed file with 14 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -21,6 +21,8 @@ class BecomeManager < JoinGroup module Decorators module Email # Can actually place any decorators for that are used specifically for emails here module Invitations class Base def subject @@ -58,4 +60,15 @@ def template end end end # We can actually place our presenters in a module like this one: # removing word "Presenter" from the class name of course... module Views end end # And use them invitation = "Decorators::Email::#{invitation.class.name}".constantize.new mail(subject: invitation.subject) render invitation.template -
stepantubanov created this gist
Mar 9, 2012 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,61 @@ # Models module Invitations class Base belongs_to :sender belongs_to :recipient end class JoinGroup < Base ... end class BecomeManager < JoinGroup ... end end # Each has different email subject and body. # The problem: do not want to add "email_subject" and "email_template" fields to the models. # Solution: May be something like module Decorators module Email module Invitations class Base def subject "Join our cool website" end def template "invitation_base" end end class JoinGroup < Base def subject "You have been invited to join #{group.name}" end def template "invitation_join_group" end end class BecomeManager < Base def subject # Example of some logic that might be used if recipient.member_of?(group) "You have been invited to manage #{subordinate.name}" else "You have been invited to join #{group.name} and manage #{subordinate.name}" end end def template "invitation_become_manager" end end end end end