WebFaction
Community site: login faq

The demo Rails app that I'm using is from Michael Hartl's Rails tutorial at http://ruby.railstutorial.org/chapters/a-demo-app .

I've successfully deployed this demo SQLite-based Rails app to WebFaction by following the instructions at http://docs.webfaction.com/software/rails.html on deploying Rails with Capistrano. I was able to get the app to work on WebFaction, but I had to change the production setup to SQLite (using the procedure described in the troubleshooting section) in order to do so. As you know, SQLite is easy to work with and is thus suitable for a learning exercise. However, Postgres is the way to go for a serious app that can handle lots of traffic, and SQLite is the database version of training wheels.

I've successfully managed to create a demo Rails app in Postgres locally.

What I'm still trying to do is deploy this Postgres demo Rails app on WebFaction. The procedure at http://docs.webfaction.com/software/rails.html on using Capistrano to deploy Rails isn't enough. I should be seeing an option to add users at http://testrails2.doppler.webfactional.com/users , but I'm instead getting the "We're sorry, but something went wrong." page. Based on the error messages (which I've printed out at the end of this message), it sounds like I need to create a Postgres database here on WebFaction. I see that the Rails page on WebFaction includes instructions on how to set up a database, but how do I make it accessible to this app?

When I enter "rake db:create:all", the first line of the LONG error message I see on the screen output is:

FATAL:  no pg_hba.conf entry for host "[local]", user "jhsu", database "postgres", SSL off

The contents in the production.log page are:

Connecting to database specified by database.yml
Started GET "/users" for 74.5.74.201 at 2013-03-28 05:29:20 +0000

PG::Error (FATAL: no pg_hba.conf entry for host "[local]", user "jhsu", database "demo_production", SSL off ): activerecord (3.2.12) lib/active_record/connection_adapters/postgresql_adapter.rb:1208:in initialize' activerecord (3.2.12) lib/active_record/connection_adapters/postgresql_adapter.rb:1208:innew' activerecord (3.2.12) lib/active_record/connection_adapters/postgresql_adapter.rb:1208:in connect' activerecord (3.2.12) lib/active_record/connection_adapters/postgresql_adapter.rb:326:ininitialize' activerecord (3.2.12) lib/active_record/connection_adapters/postgresql_adapter.rb:28:in new' activerecord (3.2.12) lib/active_record/connection_adapters/postgresql_adapter.rb:28:inpostgresql_connection' activerecord (3.2.12) lib/active_record/connection_adapters/abstract/connection_pool.rb:315:in new_connection' activerecord (3.2.12) lib/active_record/connection_adapters/abstract/connection_pool.rb:325:incheckout_new_connection' activerecord (3.2.12) lib/active_record/connection_adapters/abstract/connection_pool.rb:247:in block (2 levels) in checko$ activerecord (3.2.12) lib/active_record/connection_adapters/abstract/connection_pool.rb:242:inloop' activerecord (3.2.12) lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in block in checkout' /usr/local/lib/ruby19/ruby/1.9.1/monitor.rb:211:inmon_synchronize' activerecord (3.2.12) lib/active_record/connection_adapters/abstract/connection_pool.rb:239:in checkout' activerecord (3.2.12) lib/active_record/connection_adapters/abstract/connection_pool.rb:102:inblock in connection' /usr/local/lib/ruby19/ruby/1.9.1/monitor.rb:211:in mon_synchronize' activerecord (3.2.12) lib/active_record/connection_adapters/abstract/connection_pool.rb:101:inconnection' activerecord (3.2.12) lib/active_record/connection_adapters/abstract/connection_pool.rb:410:in retrieve_connection' activerecord (3.2.12) lib/active_record/connection_adapters/abstract/connection_specification.rb:171:inretrieve_connecti$ activerecord (3.2.12) lib/active_record/connection_adapters/abstract/connection_specification.rb:145:in connection' activerecord (3.2.12) lib/active_record/query_cache.rb:67:inrescue in call' activerecord (3.2.12) lib/active_record/query_cache.rb:61:in call' activerecord (3.2.12) lib/active_record/connection_adapters/abstract/connection_pool.rb:479:incall' actionpack (3.2.12) lib/action_dispatch/middleware/callbacks.rb:28:in block in call' activesupport (3.2.12) lib/active_support/callbacks.rb:405:in_run1285076083195215389call1393867088726063903callb$ activesupport (3.2.12) lib/active_support/callbacks.rb:405:in __run_callback' activesupport (3.2.12) lib/active_support/callbacks.rb:385:in_run_call_callbacks' activesupport (3.2.12) lib/active_support/callbacks.rb:81:in run_callbacks' actionpack (3.2.12) lib/action_dispatch/middleware/callbacks.rb:27:incall' actionpack (3.2.12) lib/action_dispatch/middleware/remote_ip.rb:31:in call' actionpack (3.2.12) lib/action_dispatch/middleware/debug_exceptions.rb:16:incall' activerecord (3.2.12) lib/active_record/connection_adapters/abstract/connection_pool.rb:239:in checkout' activerecord (3.2.12) lib/active_record/connection_adapters/abstract/connection_pool.rb:102:inblock in connection' /usr/local/lib/ruby19/ruby/1.9.1/monitor.rb:211:in mon_synchronize' activerecord (3.2.12) lib/active_record/connection_adapters/abstract/connection_pool.rb:101:inconnection' activerecord (3.2.12) lib/active_record/connection_adapters/abstract/connection_pool.rb:410:in retrieve_connection' activerecord (3.2.12) lib/active_record/connection_adapters/abstract/connection_specification.rb:171:inretrieve_connecti$ activerecord (3.2.12) lib/active_record/connection_adapters/abstract/connection_specification.rb:145:in connection' activerecord (3.2.12) lib/active_record/query_cache.rb:67:inrescue in call' activerecord (3.2.12) lib/active_record/query_cache.rb:61:in call' activerecord (3.2.12) lib/active_record/connection_adapters/abstract/connection_pool.rb:479:incall' actionpack (3.2.12) lib/action_dispatch/middleware/callbacks.rb:28:in block in call' activesupport (3.2.12) lib/active_support/callbacks.rb:405:in_run1285076083195215389call1393867088726063903callb$ activesupport (3.2.12) lib/active_support/callbacks.rb:405:in __run_callback' activesupport (3.2.12) lib/active_support/callbacks.rb:385:in_run_call_callbacks' activesupport (3.2.12) lib/active_support/callbacks.rb:81:in run_callbacks' actionpack (3.2.12) lib/action_dispatch/middleware/callbacks.rb:27:incall' actionpack (3.2.12) lib/action_dispatch/middleware/remote_ip.rb:31:in call' actionpack (3.2.12) lib/action_dispatch/middleware/debug_exceptions.rb:16:incall' actionpack (3.2.12) lib/action_dispatch/middleware/show_exceptions.rb:56:in call' railties (3.2.12) lib/rails/rack/logger.rb:32:incall_app' railties (3.2.12) lib/rails/rack/logger.rb:16:in block in call' activesupport (3.2.12) lib/active_support/tagged_logging.rb:22:intagged' railties (3.2.12) lib/rails/rack/logger.rb:16:in call' actionpack (3.2.12) lib/action_dispatch/middleware/request_id.rb:22:incall' rack (1.4.5) lib/rack/methodoverride.rb:21:in call' rack (1.4.5) lib/rack/runtime.rb:17:incall' activesupport (3.2.12) lib/active_support/cache/strategy/local_cache.rb:72:in call' rack (1.4.5) lib/rack/lock.rb:15:incall' rack-cache (1.2) lib/rack/cache/context.rb:136:in forward' rack-cache (1.2) lib/rack/cache/context.rb:245:infetch' rack-cache (1.2) lib/rack/cache/context.rb:185:in lookup' rack-cache (1.2) lib/rack/cache/context.rb:66:incall!' rack-cache (1.2) lib/rack/cache/context.rb:51:in call' railties (3.2.12) lib/rails/engine.rb:479:incall' railties (3.2.12) lib/rails/application.rb:223:in call' actionpack (3.2.12) lib/action_dispatch/middleware/debug_exceptions.rb:16:incall' actionpack (3.2.12) lib/action_dispatch/middleware/show_exceptions.rb:56:in call' railties (3.2.12) lib/rails/rack/logger.rb:32:incall_app' railties (3.2.12) lib/rails/rack/logger.rb:16:in block in call' activesupport (3.2.12) lib/active_support/tagged_logging.rb:22:intagged' railties (3.2.12) lib/rails/rack/logger.rb:16:in call' actionpack (3.2.12) lib/action_dispatch/middleware/request_id.rb:22:incall' rack (1.4.5) lib/rack/methodoverride.rb:21:in call' rack (1.4.5) lib/rack/runtime.rb:17:incall' activesupport (3.2.12) lib/active_support/cache/strategy/local_cache.rb:72:in call' rack (1.4.5) lib/rack/lock.rb:15:incall' rack-cache (1.2) lib/rack/cache/context.rb:136:in forward' rack-cache (1.2) lib/rack/cache/context.rb:245:infetch' rack-cache (1.2) lib/rack/cache/context.rb:185:in lookup' rack-cache (1.2) lib/rack/cache/context.rb:66:incall!' rack-cache (1.2) lib/rack/cache/context.rb:51:in call' railties (3.2.12) lib/rails/engine.rb:479:incall' railties (3.2.12) lib/rails/application.rb:223:in call' railties (3.2.12) lib/rails/railtie/configurable.rb:30:inmethod_missing' passenger (3.0.11) lib/phusion_passenger/rack/request_handler.rb:96:in process_request' passenger (3.0.11) lib/phusion_passenger/abstract_request_handler.rb:513:inaccept_and_process_next_request' passenger (3.0.11) lib/phusion_passenger/abstract_request_handler.rb:274:in main_loop' passenger (3.0.11) lib/phusion_passenger/rack/application_spawner.rb:206:instart_request_handler' passenger (3.0.11) lib/phusion_passenger/rack/application_spawner.rb:79:in block in spawn_application' passenger (3.0.11) lib/phusion_passenger/utils.rb:479:insafe_fork' passenger (3.0.11) lib/phusion_passenger/rack/application_spawner.rb:64:in spawn_application' passenger (3.0.11) lib/phusion_passenger/spawn_manager.rb:264:inspawn_rack_application' passenger (3.0.11) lib/phusion_passenger/spawn_manager.rb:137:in spawn_application' passenger (3.0.11) lib/phusion_passenger/spawn_manager.rb:275:inhandle_spawn_application' passenger (3.0.11) lib/phusion_passenger/abstract_server.rb:357:in server_main_loop' passenger (3.0.11) lib/phusion_passenger/abstract_server.rb:206:instart_synchronously' passenger (3.0.11) helper-scripts/passenger-spawn-server:99:in `<main>'

asked 26 Mar '13, 23:45

dopplervalue...
45158
accept rate: 100%

edited 28 Mar '13, 00:45


You shouldn't need superuser privileges in PostgreSQL to deploy your Rails app, provided that you create your PostgreSQL database and database user (via our control panel) prior to deploying your app and ensure that your app is configured to use that database and user.

Regarding the i18n error, can you please update your original question to include the complete error message (or a link to it pasted on an external site)?

permanent link

answered 27 Mar '13, 11:31

seanf
12.2k41836
accept rate: 37%

I gave it another go and updated this question to include the error messages I'm getting.

(28 Mar '13, 00:46) dopplervalue...

Looks to me like you have an invalid database name and database user name. That is, you're attempting to log in to the "postgres" database instead of one of your own databases, and you're using a PostgreSQL database username that doesn't seem to exist in our system.

Please adjust your database.yml so that:

  • You're using a PostgreSQL database that appears at https://my.webfaction.com/databases
  • You're using a PostgreSQL database user that appears at https://my.webfaction.com/database-users and that has permission to access your database

More info is available here: Using a Database with a Ruby on Rails Application

(28 Mar '13, 10:12) seanf

OK, I followed the instructions on configuring the database. I added the Postgres database to my WebFaction account, I installed the Postgres gem on my WebFaction app, and I updated my config/database.yml file. I was finally able to get the "rake db:create:all" and "rake db:migrate" commands to work.

I'm closer to getting this working, but I'm still not there yet. I still get the "We're sorry" message on the http://testrails2.doppler.webfactional.com/users page.

The production.log file shows:

Connecting to database specified by database.yml
Started GET "/users" for 74.5.78.212 at 2013-03-28 19:28:52 +0000
Processing by UsersController#index as HTML
  Rendered users/index.html.erb within layouts/application (2.1ms)
Completed 500 Internal Server Error in 67ms

ActionView::Template::Error (application.css isn't precompiled):
    2: <html>
    3: <head>
    4:   <title>Demo</title>
    5:   <%= stylesheet_link_tag    "application", :media => "all" %>
    6:   <%= javascript_include_tag "application" %>
    7:   <%= csrf_meta_tags %>
    8: </head>
  app/views/layouts/application.html.erb:5:in `_app_views_layouts_application_h$
  app/controllers/users_controller.rb:7:in `index'
(28 Mar '13, 14:34) dopplervalue...

You can either add config.assets.compile = true to your production.rb, or run rake assets:precompile to precompile your assets.

(28 Mar '13, 14:41) seanf

Thanks, seanf. I am pleased to report that after executing the command "rake assets:precompile" and then entering "./bin/restart" from the WebFaction app's root directory, my app now works on WebFaction (and not just locally).

(28 Mar '13, 15:17) dopplervalue...
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×108
×32
×20

question asked: 26 Mar '13, 23:45

question was seen: 4,637 times

last updated: 28 Mar '13, 15:17

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM