I am using sendgrid-ruby gem to send an email template but it is returning an error:
Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true
My code is as follows:
@sendgrid = SendGrid::API.new(api_key: 'api_key', host: 'localhost')
result = @sendgrid.client.mail._('send').post(request_body: template)
My development.rb:
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
config.action_mailer.asset_host = 'http://localhost:3000'
Any idea why it is returning this error? I have been through the gem docs but can't find anything regarding this error.
I am using rails 5 with ruby 2.6.5.
In my case, I implemented it like this in
config/environments/[xxx].rb
: