Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Help Setting up Ruby on Rails and MySQL - Reward Offered

I am desperately in need of help from any charitable ruby/rails experts out there. I really want to learn RoR, but I can't get anywhere because every time I get to the stage where I need to connect to the database, something is messed up. Here's what I've got going at the moment.

[ Mac OSX 10.6.6 -- Ruby 1.9.2 -- Rails 3.0.5 -- MySQL 5.5.10 ]

All of these are the latest versions, freshly installed, and running smoothly. I also have rvm installed. All I want to know is how I can set up a new Rails project using a MySQL database and connect to it properly. I have spent countless hours googling around and getting error after error after error.

Can anyone help me out by outlining step by step how I can just get a working rails project connected to a mysql database? If anyone can help me with this I will not only owe you my life, but I will make amazing web and interface designs for you for free and/or collaborate on your next project as a UI designer. I will in addition give you free photoshop/graphics advising for life.

I want to learn rails so so bad, but I am in over my head right now with this file configuration stuff and wasting massive amounts of time. Please help!

like image 818
Jeff Escalante Avatar asked Mar 20 '11 05:03

Jeff Escalante


1 Answers

You'll owe me your life!!!! WOW! Seriously, try this:

rails new example -d mysql

config.database.yml created

development:
  adapter: mysql2  
  encoding: utf8
  database: example_development
  pool: 5
  username: root
  password:
  socket: /var/run/mysqld/mysqld.sock

Go into your new project

cd example

Then install gems needed (mysql2)

bundle install

Then create your database

rake db:create

Profit!

If you can't use /var/run/mysqld/mysqld.sock as a pointer to connect to your mysql, then edit it to look like this https://gist.github.com/878434 and customize the port and username/password

like image 96
Jesse Wolgamott Avatar answered Nov 15 '22 01:11

Jesse Wolgamott