Ruslan
Ruslan

Reputation: 2009

Rails Mailer does not pick up on the host

Site is in sub-directory /app

In development.rb:

config.action_mailer.default_url_options = {
  host: 'localhost:3000/app'
}

Url generated in the mailer item_url(1):

localhost/item/1, it should be: localhost:3000/app/item/1

How do I replace localhost with localhost:3000/app?

This is in Rails 4.1.15.

Upvotes: 0

Views: 139

Answers (2)

Ruslan
Ruslan

Reputation: 2009

Using script_name did the trick:

config.action_mailer.default_url_options = { 
  host: 'localhost', 
  port: 3000, 
  script_name: '/app' 
}

Upvotes: 1

Jason Noble
Jason Noble

Reputation: 3766

To expand on tadman's comment... Your host should only have the 'localhost' portion and a separate port option:

config.action_mailer.default_url_options = {
  host: 'localhost',
  port: 3000
}

As for making the app load under /app:

config.relative_url_root = "/app"

(See see Rails app in a subdirectory for details)

Upvotes: 1

Related Questions