WEB 服务器是 Apache + Passenger
Apache 的 virtualhost 的配置: vi /etc/httpd/conf.d/virtualhost.conf
<VirtualHost *:80>
ServerName my-domain.com
DocumentRoot /var/www/html/
RailsBaseURI /project
</VirtualHost>
这样访问程序的 URL 就是: http://my-domain.com/project/
用 Devise,在子目录中做登录与否验证,如: http://my-domain.com/project/member/admin
如果用户没登录,跳转到登录页面,应该为: http://my-domain.com/project/users/sign_in
结果却是: http://my-domain.com/users/sign_in
这显然错了。为什么这样呢?
试了 3 种 Devise 与 CanCan 的验证方式,代码如下:
1 class UsersController < ApplicationController
2 before_filter :authenticate_user!
3 # Second Authorization Example: with CanCan
4 # load_and_authorize_resource :only => :index
5 # Third Authorization Example: without CanCan
6 # before_filter :only_allow_admin, :only => [ :index ]
7 (略)
结果都一样,应该和这个无关,问题出在哪呢?