Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialEdward Jasper
2,977 PointsUsing MySql2 gem with ActiveRecord and Rails 4.0.4
Hey everyone Having an issue using ActiveRecord with the 'mysql2' gem. I'm using rails 4.0.4 There are these lines in my config/application.rb
# Pick the frameworks you want:
require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "sprockets/railtie"
# require "rails/test_unit/railtie"
when i try to run 'rails g model user' i get
invoke active_record
/Users/edjasper/.rvm/gems/ruby-2.1.1/gems/railties4.0.4/lib/rails/application/configuration.rb:110:in `database_configuration': Could not load database configuration. No such file - /Users/edjasper/Desktop/associations_challenge_8/config/database.yml (RuntimeError
any advice?
1 Answer
Maciej Czuchnowski
36,441 PointsDo you have this file and can you post its content? /Users/edjasper/Desktop/associations_challenge_8/config/database.yml
Is this Windows, Mac or Linux?
Edward Jasper
2,977 PointsEdward Jasper
2,977 PointsHey Maciej, thanks for the help!
Maciej Czuchnowski
36,441 PointsMaciej Czuchnowski
36,441 PointsOK, so you basically HAVE TO have that file with that exact name and configure your database there. You can rename this example file and make it just database.yml. Then you have to put your username and password that you use for your mysql (root and empty password may work, depends on your configuration; read up on using mysql).
Very important: if you're using Git, add this file to the list of files that are ignored by Git (it's the file named .gitignore in your project folder). The production server will probably configure its own file (e.g. Heroku) and you don't want to share your personal stuff with people on Git ;).