Help Setting up Ruby on Rails and MySQL - Reward Offered

不打扰是莪最后的温柔 提交于 2020-01-13 10:44:06

问题


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!


回答1:


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




回答2:


Give a look at this post here :http://freddyandersen.wordpress.com/2010/10/03/mysql-5-5-snow-leopard-and-rails/



来源:https://stackoverflow.com/questions/5366934/help-setting-up-ruby-on-rails-and-mysql-reward-offered

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!