ruby on rails - Devise Invitable send different emails based on the type of user -
i using devise_invitable in previous versions send different invitation emails different user roles. example, admin user sent different invitation regular user. send different emails users did following:
@user = user.invite!(params[:user], current_user) |u| u.skip_invitation = true end if params[:admin_id] # admin invite @user.deliver_invitation email = notificationmailer.admin_invite_message(@user, @venue, @from, @subject, @content) else @user.deliver_invitation notificationmailer.user_invite_message(@user, @from, @subject, @content) end
this type of approach gives great deal of flexibility. newest changes way token generate (see below), no longer possible use approach.
# generates new random token invitation, , stores time # token being generated def generate_invitation_token raw, enc = devise.token_generator.generate(self.class, :invitation_token) @raw_invitation_token = raw self.invitation_token = enc end
using resource.invitation_token yields encrypted version of token , there no way grab raw token notificationmailer can send user.
any tips , work arounds appreciated.
(opened issue on devise invitable github)
to access @raw_invitation_token need add: attr_reader :raw_invitation_token
user
model.
Comments
Post a Comment