zave
zave

Reputation: 145

Heroku/Devise throwing this error: ActionView::Template::Error (Invalid :protocol option: 0):

When I try to use email features of my otherwise successfully deployed Rails 4 application, I get this error:

ActionView::Template::Error (Invalid :protocol option: 0): 

Here is the log of that request:

app[web.1]: Started POST "/users" for 000.000.000.00 at 2014-08-14 21:37:43 +0000
heroku[router]: at=info method=POST path="/users" host=myapp-staging.heroku.com request_id=ef867e68-3f4d-4b3e-      a6bb-83c288e893db fwd="000.000.000.00" dyno=web.1 connect=2ms service=746ms status=500 bytes=1676
app[web.1]:   Rendered devise/mailer/confirmation_instructions.html.erb (1.5ms)
app[web.1]: 
app[web.1]: ActionView::Template::Error (Invalid :protocol option: 0):
app[web.1]:     2: 
app[web.1]:     3: <p>You can confirm your account email through the link below:</p>
app[web.1]:     4: 
app[web.1]:     5: <p><%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %></p>
app[web.1]:   app/views/devise/mailer/confirmation_instructions.html.erb:5:in `_app_views_devise_mailer_confirmation_instructions_html_erb___2108085566880241107_70117259868780'
app[web.1]: 
app[web.1]: 
app[web.1]: Completed 500 Internal Server Error in 723ms

This is in my environment.rb

ActionMailer::Base.smtp_settings = {
:address              => 'smtp.sendgrid.net',
:port                 => '587',
:authentication       => :plain,
:user_name            => ENV['SENDGRID_USERNAME'],
:password             => ENV['SENDGRID_PASSWORD'],
:domain               => 'heroku.com',
:enable_starttls_auto => true
}

This is in my production.rb:

config.action_mailer.raise_delivery_errors = false
config.action_mailer.perform_deliveries = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.default_url_options = { host: :'myapp-staging.herokuapp.com' }
config.action_mailer.default :charset => "utf-8"

As you can see, I'm using the SendGrid addon. Has anyone seen this error and could you point me toward a potential solution?

Upvotes: 1

Views: 482

Answers (1)

zave
zave

Reputation: 145

I figured it out. I'd entered an errant semi colon. The value of config.action_mailer.default_url_options in production.rb should read thusly:

config.action_mailer.default_url_options = { host: 'helloworkout-staging.herokuapp.com' }

Upvotes: 1

Related Questions