ruby-on-rails – 从子目录运行Rails Passenger Devise?
发布时间:2020-12-16 19:41:19 所属栏目:百科 来源:网络整理
导读:我有一个服务器A代表服务器B上的/ rails的所有流量. 所以我设置这个虚拟主机,大多数事情工作…好的. link_to已损坏,并为/ users而不是/ rails / users生成URL,但是我可以解决这个问题. 如果我将config.action_controller.relative_url_root设置为/ rails,那
我有一个服务器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 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |