Search code examples
ruby-on-railsheroku

Deploy a subdirectory to Heroku


I have one 'super' repository in GitHub which will contain several applications I would like to deploy to Heroku. Here is an example of my repository.

/app
  /.git
  /website <-- would like to deploy this to Heroku

When I try to push using the following command:

$ git push heroku master

I get the following error:

Heroku push rejected, no Rails or Rack app detected.

How do I deploy a subdirectory to Heroku?


Solution

  • This can be accomplished by putting a config.ru in your root directory that tells Heroku where to find your app. For example, with Rails 3, try a config.ru like this in your root directory:

    WEBSITE_SUBDIR = 'website'
    require "#{WEBSITE_SUBDIR}/config/environment"
    run YourApplicationName::Application
    

    And on Rails 2.x, you'll need something like this:

    WEBSITE_SUBDIR = 'website'
    require "#{WEBSITE_SUBDIR}/config/environment"
    use Rails::Rack::LogTailer
    use Rails::Rack::Static
    run ActionController::Dispatcher.new