Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I get my rails controller to work with a subdomain through Passenger?
    primarykey
    data
    text
    <p>So this works for me in development mode, but when I attempt to deploy my rails app using passenger, my controller doesn't seem to be called.</p> <p>I have set up a cname record for API to www.example.com. Also, I'm using Rails 3.2 and Ruby 1.9.3.</p> <p>Here's the relevant portion of my <code>routes.rb</code> file.</p> <pre><code># API constraints :subdomain =&gt; 'api' do scope :module =&gt; 'api' do #:constraints =&gt; { :format =&gt; :json } do match '*skippydoo' =&gt; redirect('/'), :format =&gt; :html root :to =&gt; 'pages#developer', :format =&gt; :html end end </code></pre> <p>Here's the Apache configuration:</p> <pre><code># PassengerHighPerformance on PassengerMaxPoolSize 12 PassengerPoolIdleTime 1500 # PassengerMaxRequests 1000 PassengerStatThrottleRate 120 # RackAutoDetect Off # RailsAutoDetect Off NameVirtualHost 10.28.124.130:80 &lt;VirtualHost 10.28.124.130:80&gt; ServerName application.example.com ServerAlias application DocumentRoot /var/www/application/current/public/ &lt;Directory /var/www/application/current/public&gt; Options +FollowSymLinks AllowOverride All Order allow,deny allow from all &lt;/Directory&gt; 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] &lt;/VirtualHost&gt; &lt;VirtualHost 10.28.124.130:80&gt; ServerName api.application.example.com ServerAlias api.application DocumentRoot /var/www/application-api/current/public &lt;Directory /var/www/application-api/current/public&gt; Options +FollowSymLinks AllowOverride All Order allow,deny allow from all &lt;/Directory&gt; RackBaseURI / RackEnv staging &lt;/VirtualHost&gt; </code></pre> <p>This just renders some documentation I wrote describing my API.</p> <p>I can switch the document root to some empty directory and get that render, so I know Apache is working correctly. The <code>application-api</code> directory is a symlink to my deployed application.</p> <p>My API controller lives in <code>$RAILS_ROOT/app/controllers/api/pages_controller.rb</code>, but the one that is actually doing the work is <code>$RAILS_ROOT/app/controllers/pages_controller.rb</code></p> <pre><code>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) </code></pre> <p>So, what gives? Why's it work in development but not production?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload