How to send custom invitation using devise_invitab

2020-03-30 16:31发布

问题:

I am new at ruby and using devise_invitable gem for invitations. Every instruction is sending properly. Now i want to add a custom subject which will have an invitee name and board name and custom content which will have same things as subject. How can i do this in following action method without using extra custom code etc?

def AddMember
      board = current_user.boards.find(params[:id])  
        # simply invite user ! 
        invitee=User.invite!({:email => (params[:email])}, current_user)
        board.members << User.find_by_email(params[:email]) 
        msg = "invitation sent"
        render json: msg,status: :ok
        return
      end

      msg = "some error occured - member adding failed"
      render json: msg,status: 500

    end

回答1:

Follow the instructions here.

It would just be a case of editing the view template for the view.

Firstly add these lines to your environment.rb file in your Rails App.

config.to_prepare do
  Devise::Mailer.layout "email" # email.haml or email.erb
end

Then edit the email.erb or email.haml to create your custom layout.