したがって、これは開発モードでは機能しますが、パッセンジャーを使用して 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)
それで、何が得られますか?開発では機能するのに、本番環境では機能しないのはなぜですか?