Created
October 8, 2013 19:15
-
-
Save bruchu/6889955 to your computer and use it in GitHub Desktop.
Below changes go with https://github.com/bruchu/devise_invitable/commit/01190126128c3ad579a1a3c876c9ba341337c38c to be able to pass additional email context to devise_invitable :invitation_instructions. The changes will work with devise-async.
This file contains 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
self.user = User.invite!({ :email => self.email, :invitation_context => { :message => self.message } }, self.inviting_user) |
This file contains 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
<p>Hello <%= @resource.email %>!</p> | |
<p>Someone has invited you to <%= root_url %>, you can accept it through the link below.</p> | |
<p><%= link_to 'Accept invitation', accept_invitation_url(@resource, :invitation_token => @resource.invitation_token) %></p> | |
<% unless @mailer_context[:message].blank? %> | |
<p>Additional message:</p> | |
<blockquote> | |
<%= @mailer_context[:message] %> | |
</blockquote> | |
<% end %> | |
<p>If you don't want to accept the invitation, please ignore this email.<br /> | |
Your account won't be created until you access the link above and set your password.</p> |
This file contains 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
class User < ActiveRecord::Base | |
attr_accessible :invitation_context | |
end |
This file contains 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
class UserMailer < Devise::Mailer | |
helper :application | |
def invitation_instructions(record, token, opts={}) | |
@mailer_context = opts | |
super(record, token, opts) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment