I''ve been struggling with deployment of a camping app on heroku for two days now and I just can''t get it to work. I also tried cloning someone elses github repo (Camping-base) that supposedly worked on heroku but it didn''t work for me. Is there a magical way of going about it? Let''s assume I have a single file app with some basic setup and a sqlite database that on heroku would obviously have to change to postgres. Thanks in advance. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/camping-list/attachments/20111113/9a31f0ed/attachment.html>
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
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 >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/camping-list/attachments/20111113/94ec2ca2/attachment.html>
On Sun, Nov 13, 2011 at 18:27, Piotr S <thisredoned at gmail.com> 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.See http://devcenter.heroku.com/articles/rack#database_access for how to connect ActiveRecord to the database. Just remember that the free version of Heroku doesn''t include database support.
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 <http://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 <http://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 list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/camping-list/attachments/20111113/50cd07ce/attachment.html>
THANK YOU. I got a Camping app working on Heroku last year, and it was great, but when I tried it again a few weeks ago with a new app, the way I''d done it didn''t work anymore and I never did figure it out. I''m very grateful for some working instructions. :) On 11/13/11 1:20 PM, Philippe Monnet 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 <http://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 <http://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 list >> Camping-list at rubyforge.org >> http://rubyforge.org/mailman/listinfo/camping-list > > > > This body part will be downloaded on demand.-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/camping-list/attachments/20111113/66cf64d8/attachment-0001.html>
Thanks for your answer. I still can''t get it to work. I had to change activerecord to active_record in config.ru so it doesn''t give me ''no such file to load'' error. Still there is a error that I also had before from postgresql_adapter.rb saying: PGError: ERROR: invalid value for parameter "client_min_messages" : "" (ActiveRecord::StatementInvalid) 2011/11/13 Philippe Monnet <ruby at monnet-usa.com>> 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 >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/camping-list/attachments/20111113/dd1e9d32/attachment.html>
> Just remember that the free version of Heroku doesn''t include database support.Whaaa? Since when? http://www.heroku.com/pricing#0-0 says you get 5MB for $0. Also, I''m pretty sure .gems is deprecated, and you have to use Bundler soon.
On Mon, Nov 14, 2011 at 19:44, Steve Klabnik <steve at steveklabnik.com> wrote:>> Just remember that the free version of Heroku doesn''t include database support. > > Whaaa? Since when? http://www.heroku.com/pricing#0-0 says you get 5MB for $0.Hm? Really? It seems I got the wrong impression after their price change? Oh well, there''s still that ugly client_min_messages-bug which I haven''t been able to solve :/
Thanks for the great instructions Phillippe. Are you French? Or perhaps Canadian? On Sun, Nov 13, 2011 at 6:20 PM, Philippe Monnet <ruby at 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 at rubyforge.orghttp://rubyforge.org/mailman/listinfo/camping-list > > > > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/camping-list/attachments/20111118/d28a78c1/attachment-0001.html>