I've done this by overriding the invites controller, the instructions to do this are in the devise_invitable main page on github so I won't go into it here.
For security, I created a new table that holds extra invitation information so that the email accept link does not hold the group link (my groups are by private invites only so I don't want a invited user to alter the invite url in the email and potentially add other groups which they were not invited).
The new table is indexed by the user id after devise_invitable creates it in the user table.
class Users::InvitesController < Devise::InvitationsController
.
.
def create
# make sure the current user is connected to this object for security
if @object.has_connection_with(current_user)
# perform the invite
self.resource = resource_class.invite!(params[resource_name], current_inviter)
#since we invite based on object, we must reference this object once the user accepts, so we store this in our Invites table
object_invite = Invite.new(:invitable_type => @object.class.name, :invitable_id => @object.id, :user_id => self.resource.id, :inviter_id => current_inviter.profile.id)
object_invite.save!
if resource.errors.empty?
set_flash_message :notice, :send_instructions, :email => self.resource.email
#respond_with resource, :location => after_invite_path_for(resource)
render :json => {:status => 'success'} and return
else
respond_with_navigational(resource) { render_with_scope :new }
end
end
end
Then in your update method (again in the same controller) you can find() the Invites record and pull the required info that will allow you to connect the new user to the group.
The only issue left is how to add additional parameters to the email, like group name, which I have yet to resolve.