Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connecting rails app to Amazon RDS server. Works in console, but now page wont load

I am trying to use a RDS database with my rails app since eventually I want to put it on heroku. (Database is about 10gb). I had trouble getting it to connect but it seems to be working. If I go into the console I can run sphinx searches and all that I need to but when I start the server it seems to freeze or something. If I click "About your application’s environment" nothing happens. I do not get any messages in the console or anything. If I try to go to another page it just tries loading the page but does not go anywhere.

Here is what my database.yml looks like.

# development:
#   adapter: postgresql
#   encoding: unicode
#   database: musicbrainz_post
#   pool: 5
#   username: postgres
#   password:

development:
  adapter: mysql2
  #encoding: utf8
  host: musicbrainz.somestuff.amazonaws.com
  #port: 3306
  #reconnect: false
  database: musicbrainz
  username: myusername
  password: mypass

If I comment out my old database configuration it works and the pages load and everything. But I want to use the amazon database.

Does anyone know why this is? Or is there another database/host I should be using?

Any help would be great!

like image 678
Jonovono Avatar asked Oct 10 '22 14:10

Jonovono


1 Answers

After experiencing the same problem I found out what the problem was. The problem is that you need to use Ruby 1.9.3 as opposed to Ruby 1.8.7. I think the bug is occuring in the mysql2 gem.

Therefore the fix is to install Ruby 1.9.3. Here are the steps I followed:

NOTE: Before starting any of these steps, set up your terminal to "Run command as a login shell". For Ubuntu, open the terminal go to Edit -> Profile Preferences. Go to "Title and Command". Check the box next to "Run command as a login shell"

  1. Installed RVM on my system with ruby and ruby on rails bundled: https://rvm.io/rvm/install/ Command: \curl -L https://get.rvm.io | bash -s stable --rails
  2. Command: source ~/.rvm/scripts/rvm
  3. Used RVM to install OpenSSL: rvm pkg install openssl
  4. Reinstall all rubies: rvm reinstall all --force
  5. Because you are now using RVM to manage both your rubies and your gems your gem environment will be new. Therefore you must reinstall any gems. Do so by going to your project and running: bundle install
  6. Run your rails app: bundle exec rails s

Good luck!

like image 112
richardaday Avatar answered Oct 12 '22 03:10

richardaday