我有一个服务器A代表服务器B上的/ rails的所有流量.
所以我设置这个虚拟主机,大多数事情工作…好的. link_to已损坏,并为/ users而不是/ rails / users生成URL,但是我可以解决这个问题.
如果我将config.action_controller.relative_url_root设置为/ rails,那么我的路由工作就可以,除了所有的设计路由.他们指向裸露的URL.如何正确配置服务器B以了解其运行在子目录中并正确生成链接和路由?
<VirtualHost *:80> ServerName http://ec2-url.compute-1.amazonaws.com/ SetEnv RDS_HOSTNAME "mydb..." SetEnv RAILS_RELATIVE_URL_ROOT "/rails" DocumentRoot /home/ubuntu/myapp/public RailsEnv staging ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/app.log combined PassengerLogLevel 3 <Directory "/home/ubuntu/myapp/public"> Options FollowSymLinks AllowOverride None Order allow,deny Allow from all Options -MultiViews Require all granted </Directory> </VirtualHost>
我使用的是Rails 4.
解决方法
在您的环境文件中,为OmniAuth.config.full_host添加一个配置.
OmniAuth.config.full_host =’http:// myfullurl / subdir’
现在,在application_controller.rb中,添加以下方法:
def after_sign_in_path_for(resource_or_scope) path = super(resource_or_scope) "#{OmniAuth.config.full_host}#{path}" end
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。