views:

588

answers:

2

I'm creating a webservice and I want to store the source on github and run the app on heroku. I haven't seen my exact scenario addressed anywhere on the 'net so far, so I'll ask it here:

I want to have the following directory structure:

/project
  .git
  README <-- project readme file
  TODO.otl <-- project outline
  ... <-- other project-related stuff
  /my_rails_app
     app
     config
     ...
     README <-- rails' readme file 

In the above, project corresponds to http://github.com/myuser/project, and my_rails_app is the code that should be pushed to heroku. Do I need a separate branch for the rails app, or is there a simpler way that I'm missing?

I guess my project-related non-rails files could live in my_rails_app, but the rails README already lives there and it seems inconsistent to overwrite that. However, if I leave it, my github page for the rails app will contain the rails readme, which makes no sense.

Thanks,

Noah

P.S. I tried just setting it up as described above and running

git push heroku

from the main project folder. Of course, heroku doesn't know I want to deploy the subfolder:

-----> Heroku receiving push
 !     Heroku push rejected, no Rails or Rack app detected.
A: 

I would add everything underneath /my_rails_app to the Heroku git repository. Then add GitHub as a remote and add everything underneath /project to the GitHub repository. Then you can push the Rails application to Heroku (from /my_rails_app) and push the full project to GitHub (from /project).

John Topley
You're basically saying create two repos, right? One inside the other? A good though. However, I already tried that, and it doesn't work :). Github is the problem: rather than displaying the my_rails_app as a normal version-controlled folder, it's displayed as a link to a git commit reference (in this case the first few characters of the commit id of the my_rails_app git repo). So basically doing this renders github's web view useless for all intents and purposes.
Noah
You'll have to have two repos because Heroku requires its own. I have done this successfully with Heroku and GitHub, but not nested in this way. It looks like Justice might have a good answer.
John Topley
+2  A: 

Here's a simple solution that may or may not work for you.

  • Create two projects on GitHub. One project should be just the Rails app (i.e. everything inside the Rails app directory). The other project should be everything outside the Rails app directory.

  • Add the Rails app project as a git-submodule within the "container" project.

  • Now you can add Heroku as a remote on the Rails app repository separately and push it to heroku. Heroku will accept the push because it is just a Rails app with the expected directories and files.

Justice
This worked, thanks.
Noah