从子目录运行Rails + Passenger + Devise?

Ste*_*all 12 apache ruby-on-rails passenger devise omniauth

我有一台服务器A代理所有流量/rails到服务器B.

所以我设置了这个虚拟主机,大多数工作都可以......好吧.link_to被打破并生成网址而/users不是/rails/users,但我可以解决这个问题.

如果我设置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>
Run Code Online (Sandbox Code Playgroud)

我正在使用Rails 4.

Ste*_*all 5

在您的环境文件中,添加配置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
Run Code Online (Sandbox Code Playgroud)