kylefitz
By:
kylefitz

Import Ruby on Rails App From Github

November 7, 2014 4k views

I can't seem to get this app running from Github. It looks like a complete app (https://github.com/harrystech/prelaunchr) but whatever I do, it won't work on the 1 click ruby on rails droplet. Any ideas on what steps I need to take to get it up and running? There is only one guide on here, and it's not very helpful... Thanks in advance!

1 comment
  • I followed every step but constantly getting error connecting to mysql:

    root@prelaunch:/home/rails# bundle exec rails s
    => Booting WEBrick
    => Rails 3.2.11 application starting in development on http://0.0.0.0:3000
    => Call with -d to detach
    => Ctrl-C to shutdown server
    Exiting
    /usr/local/rvm/gems/ruby-2.1.3/gems/mysql2-0.3.18/lib/mysql2/client.rb:70:in `connect': Access denied for user 'root'@'localhost' (using password: NO) (Mysql2::Error)
        from /usr/local/rvm/gems/ruby-2.1.3/gems/mysql2-0.3.18/lib/mysql2/client.rb:70:in `initialize'
        from /usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-3.2.11/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `new'
        from /usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-3.2.11/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `mysql2_connection'
        from /usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:315:in `new_connection'
    

    database.yml looks like this:

    # SQLite version 3.x
    #   gem install sqlite3
    #
    #   Ensure the SQLite 3 gem is defined in your Gemfile
    #   gem 'sqlite3'
    development:
      adapter: mysql2
      database: prelaunchr
      host: localhost
    
    # Warning: The database defined as "test" will be erased and
    # re-generated from your development database when you run "rake".
    # Do not set this db to the same as development or production.
    test:
      adapter: mysql2
      database: test
      host: localhost
    
    production:
      adapter: mysql2
      database: rails
      password: XXXXXX
      host: localhost
    

    @asb can you please help somehow, I'm googling for hours but nothing helped.

3 Answers

Hi!

There are a number of things going on here that make this not as straight forward as it could be. First, prelaunchr is set up to use Postgress as it's database by default while the one-click app is pre-installed with MySql. Next, prelaunchr want to use older versions of a number of gems that come preinstalled on the image. So we need to uninstall them and install the need versions. Finally, there seems to be an issue with the default asset settings for prelaunchr.

Using the following steps, I was able to get prelaunchr up and running:

rm -rf /home/rails/*
cd  /home/rails/
git clone https://github.com/harrystech/prelaunchr.git .
nano Gemfile # Add "gem 'mysql2'"
nano config/database.yml # Change 'postgres' to 'mysql2' and add user/pass for the database
gem list | cut -d" " -f1 | xargs gem uninstall -aIx  # Uninstall gems that might conflict
bundle install
bundle exec rake db:create db:schema:load db:seed
nano config/environments/production.rb # Set `config.assets.compile = true`
chown -R rails:www-data *
service unicorn restart
  • Hey asb, Thanks for helping out!! I got through all the steps and it seemed like they all worked, but when I go to the ip (http://104.236.32.189/) it just sits and loads until getting a 504 gateway time-out from nginx.... Any idea what could be going wrong?

    I put the database info under "production", not "development", is that right? I also added gem 'mysql2' right under the first section right under gem 'activeadmin', so hopefully that's in the right place as well...

    Thanks again I love digital ocean's awesome support!

  • after running the bundle exec rake db command I get this error:

    rake aborted!
    (<unknown>): could not find expected ':' while scanning a simple key at line 7 column 1
    /usr/local/rvm/gems/ruby-2.1.3/gems/railties-3.2.11/lib/rails/application/configuration.rb:115:in database_configuration'
    /usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-3.2.11/lib/active_record/railties/databases.rake:25:in
    block (2 levels) in <top (required)>'
    /usr/local/rvm/gems/ruby-2.1.3/bin/rubyexecutablehooks:15:in eval'
    /usr/local/rvm/gems/ruby-2.1.3/bin/ruby_executable_hooks:15:in
    <main>'
    Tasks: TOP => db:create => db:load_config
    (See full trace by running task with --trace)

  • The previous error looks like it was happening because I had the mysql password wrong. I fixed that but it's still just timing out...

  • Doh, I didn't start the server at the end! I got it working finally, thanks for the sweet walkthrough!!! I noticed I have to go to http://104.236.32.189:3000/ to get it to work, is that because of unicorn? Is there any way to go to the regular IP address and get taken to the app?

  • @kylefitz Glad to hear you got it working!

    To get it running on port 80, you'll want to use the Nginx instance as a reverse proxy. The sample Rails app runs on port 8080, so we need to change the Nginx configuration for port 3000. Edit the file /etc/nginx/nginx.conf and change the line:

    upstream app_server { server 127.0.0.1:8080 fail_timeout=0; }
    

    to

    upstream app_server { server 127.0.0.1:3000 fail_timeout=0; }
    

    Than restart Nginx with: sudo service nginx restart

  • Maybe I should post a comment instead :)

    I get a really weird error, and hours of googling isn't helping. My error is in the bottom of the post.

    I've supplied the correct password both in the database.yml (and I've tried removing it from it) and I resupply it when the rake asks me to, but still nothing. What am I doing wrong? :)

    Access denied for user 'root'@'localhost' (using password: NO). 
    Please provide the root password for your mysql installation
    >sliver12
    fe_sendauth: no password supplied
    /usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-3.2.11/lib/active_record/connection_adapters/postgresql_adapter.rb:1208:in `initialize'
    /usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-3.2.11/lib/active_record/connection_adapters/postgresql_adapter.rb:1208:in `new'
    /usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-3.2.11/lib/active_record/connection_adapters/postgresql_adapter.rb:1208:in `connect'
    /usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-3.2.11/lib/active_record/connection_adapters/postgresql_adapter.rb:326:in `initialize'
    /usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-3.2.11/lib/active_record/connection_adapters/postgresql_adapter.rb:28:in `new'
    /usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-3.2.11/lib/active_record/connection_adapters/postgresql_adapter.rb:28:in `postgresql_connection'
    /usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:315:in `new_connection'
    /usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:325:in `checkout_new_connection'
    /usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:247:in `block (2 levels) in checkout'
    /usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `loop'
    /usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `block in checkout'
    /usr/local/rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
    /usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:239:in `checkout'
    /usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:102:in `block in connection'
    /usr/local/rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
    /usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:101:in `connection'
    /usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:410:in `retrieve_connection'
    /usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_specification.rb:171:in `retrieve_connection'
    /usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_specification.rb:145:in `connection'
    /usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-3.2.11/lib/active_record/railties/databases.rake:130:in `rescue in create_database'
    /usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-3.2.11/lib/active_record/railties/databases.rake:74:in `create_database'
    /usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-3.2.11/lib/active_record/railties/databases.rake:62:in `block (3 levels) in <top (required)>'
    /usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-3.2.11/lib/active_record/railties/databases.rake:62:in `each'
    /usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-3.2.11/lib/active_record/railties/databases.rake:62:in `block (2 levels) in <top (required)>'
    /usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.4.2/lib/rake/task.rb:240:in `call'
    /usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.4.2/lib/rake/task.rb:240:in `block in execute'
    /usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.4.2/lib/rake/task.rb:235:in `each'
    /usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.4.2/lib/rake/task.rb:235:in `execute'
    /usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.4.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
    /usr/local/rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
    /usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.4.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
    /usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.4.2/lib/rake/task.rb:165:in `invoke'
    /usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.4.2/lib/rake/application.rb:150:in `invoke_task'
    /usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.4.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
    /usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.4.2/lib/rake/application.rb:106:in `each'
    /usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.4.2/lib/rake/application.rb:106:in `block in top_level'
    /usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.4.2/lib/rake/application.rb:115:in `run_with_threads'
    /usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.4.2/lib/rake/application.rb:100:in `top_level'
    /usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.4.2/lib/rake/application.rb:78:in `block in run'
    /usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.4.2/lib/rake/application.rb:176:in `standard_exception_handling'
    /usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.4.2/lib/rake/application.rb:75:in `run'
    /usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.4.2/bin/rake:33:in `<top (required)>'
    /usr/local/rvm/gems/ruby-2.1.3/bin/rake:23:in `load'
    /usr/local/rvm/gems/ruby-2.1.3/bin/rake:23:in `<main>'
    /usr/local/rvm/gems/ruby-2.1.3/bin/ruby_executable_hooks:15:in `eval'
    /usr/local/rvm/gems/ruby-2.1.3/bin/ruby_executable_hooks:15:in `<main>'
    Couldn't create database for {"adapter"=>"postgresql", "database"=>"prelaunchr", "host"=>"localhost"}
    rake aborted!
    Mysql2::Error: Access denied for user 'root'@'localhost' (using password: NO)
    /usr/local/rvm/gems/ruby-2.1.3/gems/mysql2-0.3.17/lib/mysql2/client.rb:70:in `connect'
    /usr/local/rvm/gems/ruby-2.1.3/gems/mysql2-0.3.17/lib/mysql2/client.rb:70:in `initialize'
    /usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-3.2.11/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `new'
    /usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-3.2.11/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `mysql2_connection'
    /usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:315:in `new_connection'
    /usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:325:in `checkout_new_connection'
    /usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:247:in `block (2 levels) in checkout'
    /usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `loop'
    /usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `block in checkout'
    /usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:239:in `checkout'
    /usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:102:in `block in connection'
    /usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:101:in `connection'
    /usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:410:in `retrieve_connection'
    /usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_specification.rb:171:in `retrieve_connection'
    /usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_specification.rb:145:in `connection'
    /usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-3.2.11/lib/active_record/model_schema.rb:308:in `clear_cache!'
    /usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-3.2.11/lib/active_record/railtie.rb:97:in `block (2 levels) in <class:Railtie>'
    /usr/local/rvm/gems/ruby-2.1.3/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:418:in `_run__3062762052597524944__prepare__810081679230357491__callbacks'
    /usr/local/rvm/gems/ruby-2.1.3/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:405:in `__run_callback'
    /usr/local/rvm/gems/ruby-2.1.3/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:385:in `_run_prepare_callbacks'
    /usr/local/rvm/gems/ruby-2.1.3/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:81:in `run_callbacks'
    /usr/local/rvm/gems/ruby-2.1.3/gems/actionpack-3.2.11/lib/action_dispatch/middleware/reloader.rb:74:in `prepare!'
    /usr/local/rvm/gems/ruby-2.1.3/gems/actionpack-3.2.11/lib/action_dispatch/middleware/reloader.rb:48:in `prepare!'
    /usr/local/rvm/gems/ruby-2.1.3/gems/railties-3.2.11/lib/rails/application/finisher.rb:47:in `block in <module:Finisher>'
    /usr/local/rvm/gems/ruby-2.1.3/gems/railties-3.2.11/lib/rails/initializable.rb:30:in `instance_exec'
    /usr/local/rvm/gems/ruby-2.1.3/gems/railties-3.2.11/lib/rails/initializable.rb:30:in `run'
    /usr/local/rvm/gems/ruby-2.1.3/gems/railties-3.2.11/lib/rails/initializable.rb:55:in `block in run_initializers'
    /usr/local/rvm/gems/ruby-2.1.3/gems/railties-3.2.11/lib/rails/initializable.rb:54:in `each'
    /usr/local/rvm/gems/ruby-2.1.3/gems/railties-3.2.11/lib/rails/initializable.rb:54:in `run_initializers'
    /usr/local/rvm/gems/ruby-2.1.3/gems/railties-3.2.11/lib/rails/application.rb:136:in `initialize!'
    /usr/local/rvm/gems/ruby-2.1.3/gems/railties-3.2.11/lib/rails/railtie/configurable.rb:30:in `method_missing'
    /home/rails/config/environment.rb:5:in `<top (required)>'
    /usr/local/rvm/gems/ruby-2.1.3/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require'
    /usr/local/rvm/gems/ruby-2.1.3/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `block in require'
    /usr/local/rvm/gems/ruby-2.1.3/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:236:in `load_dependency'
    /usr/local/rvm/gems/ruby-2.1.3/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require'
    /usr/local/rvm/gems/ruby-2.1.3/gems/railties-3.2.11/lib/rails/application.rb:103:in `require_environment!'
    /usr/local/rvm/gems/ruby-2.1.3/gems/railties-3.2.11/lib/rails/application.rb:297:in `block (2 levels) in initialize_tasks'
    /usr/local/rvm/gems/ruby-2.1.3/bin/ruby_executable_hooks:15:in `eval'
    /usr/local/rvm/gems/ruby-2.1.3/bin/ruby_executable_hooks:15:in `<main>'
    Tasks: TOP => db:schema:load => environment
    (See full trace by running task with --trace)
    
  • (Maybe I should post this as a comment and not an answer :) )

    I'm running into some errors with my password. I've tried supplying it both in the databases.yml and when the prompt asks med to, but it rejects it every time. I've been googling this for hours, with no results! What am I doing wrong :)?

    Access denied for user 'root'@'localhost' (using password: NO).
    Please provide the root password for your mysql installation

    MYPASSWORD
    fesendauth: no password supplied
    (/// heaps of code, almost all in the form of /usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-3.2.11/lib/active
    record/connectionadapters/postgresqladapter.rb:1208:in `initialize')
    Tasks: TOP => db:schema:load => environment
    (See full trace by running task with --trace)

Hey,

I've been reading this upside and down and I cant seem to get this to work.

My problem is with the mysql password. When I run "bundle exec rake db:create db:schema:load db:seed", I get:

"Access denied for user 'root'@'localhost' (using password: NO).
Please provide the root password for your mysql installation"

I haven't set the user name and password in the database.yml file, as I can't figure out where to put it. I've tried entering the information in basically every possible place, but nothing I do seems to work. I'd love some help!

  • Hey @daniel982752! The answer I gave above is based on using the pre-installed Rails "One-Click" application. The username and password are provided in the "MOTD" (message of the day). You want to use the "rails" users not root.

    If this is what it says in the MOTD:

    These instructions are stored in /root/RAILS for your review.
    You can use the following MySQL database credentials:
    DB: rails
    User: rails
    Pass: XXXXXXX
    

    This is what config/database.yml should have:

    production:
      adapter: mysql
      database: rails
      password: XXXXXXX
      host: localhost
    
  • Awesome, thanks for the answer!

    I switched user to rails via the su rails command (which might be wrong, but I'm not allowed to log into the ssh with the rails password).

    Everything worked fine until it's time to do to rake. When it returns: rake aborted!
    can't convert nil into Hash

    I've checked all the files, what am I doing wrong now?

@asb
Update: It seems I've been using the wrong password. But, now it gives me another error:
could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?

Have another answer? Share your knowledge.