ruby-on-rails – 从子目录运行Rails Passenger Devise?

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – 从子目录运行Rails Passenger Devise?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_301_1@我有一个服务器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
原文链接:https://www.f2er.com/ruby/271681.html

猜你在找的Ruby相关文章