2016-08-30 43 views
0

網站是在子目錄/appRails的梅勒不拿起上的主機

在development.rb:

localhost/item/1,它應該:在郵件item_url(1)產生

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

網址是:localhost:3000/app/item/1

如何將localhost替換爲localhost:3000/app

這是在Rails 4.1.15中。

+1

'/ app'不是有效的主機名組件。 – tadman

回答

0

使用script_name的伎倆:

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

要在tadman的評論擴大...您的主機應該只擁有「localhost」的部分和一個單獨的端口選項:

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

至於下/應用使得應用負載:

config.relative_url_root = "/app" 

(見見Rails app in a subdirectory瞭解詳細信息)

+1

該端口應該可以從'host:'中省略,因爲它在'port:'中描述。 – ollpu

+0

良好的接收,謝謝@ollpu。 –

+0

主機和端口的作品。 'relative_url_root'不。越來越近 – Ruslan