2017-03-07 55 views

回答

8

運行請問您檢查您的環境/測試。 rb,環境/開發並確保將以下內容設置爲您需要的網址:

Rails.application.routes.default_url_options[:host] = 'DESIRED URL' 
4

你可以在你的終端使用以下命令

sudo nano /etc/hosts 

## 
# Host Database 
# 
# localhost is used to configure the loopback interface 
# when the system is booting. Do not change this entry. 
## 
127.0.0.1  localhost 
255.255.255.255 broadcasthost 
::1    localhost 
192.168.56.2 qruqsp.local 









           [ Read 10 lines ] 
^G Get Help ^O WriteOut ^R Read File ^Y Prev Page ^K Cut Text ^C Cur Pos 
^X Exit  ^J Justify ^W Where Is ^V Next Page ^U UnCut Text^T To Spell 

變化127.0.0.1到本地主機,而不是UDE你的情況

刷新DNS設置與sudo dscacheutil -flushcache

改變你的域名現在rails server將與http://localhost:3000/

現在工作你也可以改變它以你喜歡的東西,例如

127.0.0.1 www.rubyrails.com

添加一行,並刷新與sudo dscacheutil -flushcache

的DNS設置現在rails server將在http://www.rubyrails.com:3000/

+0

它已經是本地主機,但仍然去ude – stackjlei

+0

你可以添加一個屏幕截圖,究竟你得到@stackjlei – supar

+0

我不能cuz它的工作:( – stackjlei

1

使用,在_path結束,而不是_url(絕對)

相關問題