所以这在开发模式下对我有用,但是当我尝试使用乘客部署我的 rails 应用程序时,我的控制器似乎没有被调用。
我已经为 www.example.com 的 API 设置了 cname 记录。另外,我使用的是 Rails 3.2 和 Ruby 1.9.3。
routes.rb
这是我文件的相关部分。
# API
constraints :subdomain => 'api' do
scope :module => 'api' do #:constraints => { :format => :json } do
match '*skippydoo' => redirect('/'), :format => :html
root :to => 'pages#developer', :format => :html
end
end
这是Apache的配置:
# PassengerHighPerformance on
PassengerMaxPoolSize 12
PassengerPoolIdleTime 1500
# PassengerMaxRequests 1000
PassengerStatThrottleRate 120
# RackAutoDetect Off
# RailsAutoDetect Off
NameVirtualHost 10.28.124.130:80
<VirtualHost 10.28.124.130:80>
ServerName application.example.com
ServerAlias application
DocumentRoot /var/www/application/current/public/
<Directory /var/www/application/current/public>
Options +FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
RackBaseURI /
RackEnv staging
ErrorDocument 503 /system/maintenance.html
RewriteEngine On
RewriteLog /var/www/application/current/log/rewrite_log
RewriteLogLevel 9
RewriteCond %{REQUEST_URI} !.(css|gif|jpg|png)$
RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ - [redirect=503,last]
</VirtualHost>
<VirtualHost 10.28.124.130:80>
ServerName api.application.example.com
ServerAlias api.application
DocumentRoot /var/www/application-api/current/public
<Directory /var/www/application-api/current/public>
Options +FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
RackBaseURI /
RackEnv staging
</VirtualHost>
这只是呈现了一些我写的描述我的 API 的文档。
我可以将文档根目录切换到某个空目录并获取该渲染,因此我知道 Apache 工作正常。该application-api
目录是我部署的应用程序的符号链接。
我的 API 控制器住在里面$RAILS_ROOT/app/controllers/api/pages_controller.rb
,但真正做这项工作的是$RAILS_ROOT/app/controllers/pages_controller.rb
Started GET "/" for 10.29.28.157 at 2012-04-26 21:12:51 -0500
Processing by PagesController#home as HTML
Rendered pages/home.html.erb within layouts/application (283.7ms)
Rendered layouts/_stylesheets.html.erb (4.4ms)
Rendered layouts/_header.html.erb (5.7ms)
Rendered layouts/_footer.html.erb (0.4ms)
Completed 200 OK in 522ms (Views: 394.4ms | ActiveRecord: 12.1ms | Solr: 0.0ms)
那么,什么给了?为什么它在开发中起作用而不是在生产中起作用?