chloerei/writings

跑起来之后,只能通过localhost访问,怎么设置?

Closed this issue · 2 comments

在局域网其他机器上访问出错:

Mongoid::Errors::DocumentNotFound in Site::ArticlesController#index
Problem: Document not found for class Space with attributes {:domain=>"192.168.56.1"}. Summary: When calling Space.find_by with a hash of attributes, all attributes provided must match a document in the database or this error will be raised. Resolution: Search for attributes that are in the database or set the Mongoid.raise_not_found_error configuration option to false, which will cause a nil to be returned instead of raising this error.

因为这个程序支持自定义域名,所以只有通过主域名访问的时候才能打开主页面。如果是局域网多台机器调试,可以这样:

  1. 在 config/app_config.yml 里面设置 host 为你想要的域名,比如 "writings.dev"
  2. 在所有用来测试的主机,包括开发机上配置 hosts,“192.168.56.1 writings.dev",其中 192.168.56.1 是你的开发机 ip。

然后重启服务,用 writings.dev 域名访问。

谢谢