Question

Devise confirmation_url is producing just a relative url with no domain such as:

http://users/confirmation?confirmation_token=...

I tried changing

confirmation_url(@resources, :confirmation_token => @resource.confirmation_token)

to

confirmation_url(:confirmation_token => @resource.confirmation_token)

but it produces the same url. I upgraded to devise 2.2.3 but same outcome. Rails 3.1.4

Update: I have set in my production.rb:

  config.action_mailer.default_url_options = { :host => 'mysubdomain.mysite.com' } 

and I tried setting

    before_filter set_actionmailer_host

    def set_actionmailer_host
      ActionMailer::Base.default_url_options[:host] = request.host_with_port
    end

to no avail in application controller (https://github.com/plataformatec/devise/issues/1567)

Update: This occurs in both development and production.

Update I can't understand why Devise isn't using the template in app/views/devise/mailer/confirmation_instructions.html.haml If I could edit that I could append the host manually: 'http://mysite.com/' + confirmation_url(... I tried setting the scoped views setting but it didn't have any effect This is a disaster, users can't confirm their registration :(

Was it helpful?

Solution

You might have missed to add the default url hosts to your environment config-files. When you run the rails g devise:install command you usually receive those instructions.

# config/environments/development.rb

# Default actiomailer url host (required by devise) 
config.action_mailer.default_url_options = { host: 'myapp.dev' }

You need this setting for all your environments.

# config/environments/production.rb

# Default actiomailer url host (required by devise) 
config.action_mailer.default_url_options = { host: 'myproductionapp.com' }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top