How do you pass a custom message to the devise invitable email? I want the inviter to include a message to the invitee, like "Hey check out this site".
I tried both including it in the attributes and setting an instance variable in the block, neither seem to be accessible from the email.
user = User.invite!(:email => share.to_user_email, :message => "hey check this out") do
@message = "hey it's me!"
end
you have to do rails generate devise_invitable:views users
then you will get new erb file app/views/users/mailer/invitation_instructions.html.erb
which you will be able to customize in any way you want
Email template will allow you to send same message for all the emails.
Here is another way/case, when you are taking message as an input from user.
model/user.rb
attr_accessor :message
controller
User.invite!({email: email}, current_user) do |user|
user.message = params[:message]
end
/views/devise/mailer/invitation_instructions.html.erb
<p>Hello <%= @resource.email %>!</p>
<p><%= @resource.message%>.</p>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With