Skip to content

Instantly share code, notes, and snippets.

@bruchu
Created October 8, 2013 19:15
Show Gist options
  • Save bruchu/6889955 to your computer and use it in GitHub Desktop.
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.
self.user = User.invite!({ :email => self.email, :invitation_context => { :message => self.message } }, self.inviting_user)
<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>
class User < ActiveRecord::Base
attr_accessible :invitation_context
end
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