Thanks for the great instructions Phillippe. Are you French? Or perhaps Canadian?
On Sun, Nov 13, 2011 at 6:20 PM, Philippe Monnet <r...@monnet-usa.com>wrote: > Here is my recipe: > > 1. Setup up up your Gems prerequisites: create a .gems file in the root > folder and list each gem version on a separate line. E.g.: > > rack --version '>= 1.2.1' > markaby --version '= 0.5' > camping --version '>= 2.1' > > 2. Create a RackUp script: create a config.ru file (still in the root > folder) for Rack's configuration. In this example myapp.rb has a main > module named MyApp: > > # config.ru > > %w(rack activerecord camping camping/session camping/reloader ).each { > | r | require r} > require 'myapp.rb' > run MyApp > > 3. Configure routes for your static assets: if you need to serve static > files from specific directories, add the following statements to config.ru > : > > use Rack::Reloader > use Rack::Static, > :urls => [ '/css', > '/js', > '/images' ], > :root => File.expand_path(File.dirname(__FILE__)) > > Note: If you need additional Rack modules insert the corresponding > statements there too. > > 4. Setup your application configuration: I'd recommend that the various > configuration files you need get grouped together into a ./config folder. > Example: > > ./config > database.yml > some.yml > ... > > Important: Do not add the database.yml file to Git so that it does NOT get > pushed to Heroku. When you first deploy to Heroku, the database.yml file > will automatically be generated to reflect the internal name that Heroku > will assign. So your main module should connect to the database like so: > > dbconfig = YAML.load(File.read('config/database.yml')) > environment = ENV['DATABASE_URL'] ? 'production' : 'development' > Camping::Models::Base.establish_connection dbconfig[environment] > > This allows you to use your local (git-unaware) database.yml when > developing and the official Heroku version when hosted. > > 5. Tweak your code for PostgreSQL when migrating your SQLite database to > PostgreSQL: take into account a stricter GROUP BY clause. PostgreSQL > requires all resulting columns from a SELECT ... GROUP BY to be explicitly > defined. > In other words if you have the following SQLite query: > SELECT * > FROM widgets > GROUP BY category > You will need to rewrite like so: > SELECT id, category, description > FROM widgets > GROUP BY category, category, description > > Hope that helps. > > Philippe > > > On 11/13/2011 10:27 AM, Piotr S wrote: > > Well yeah. I know about the gems and configu.ru. > It's the magic part of switching between databases that really gives me > the mental workout. > I'm looking for some working solutions to a problem that I'd imagine most > of the Camping hackers face because where else could we possibly deploy our > apps if not on heroku? > > You just need a .gems file (containing list of gems you use, one per >> line) and a config.ru file like this: >> >> require './my_app.rb' >> run MyApp >> >> (both in the root of the repo). >> >> Create them both, commit and it should start working. (You'll >> obviously also have to do some magic to switch to postgres, as you >> noticed.) >> >> -- Matma Rex >> > > > > _______________________________________________ > Camping-list mailing > listCamping-list@rubyforge.orghttp://rubyforge.org/mailman/listinfo/camping-list > > > > _______________________________________________ > Camping-list mailing list > Camping-list@rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list >
_______________________________________________ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list