views:

167

answers:

2

I setup my rails project "tracks" using:

$ rails --database=mysql tracks # OK
$ cd tracks
$ vim config/database.yml # correct using mysql adapter, added password spec
$ rake db:create RAILS_ENV='development' # OK
$ rake db:migrate # OK

$ ruby script/generate scaffold user name:string password:string email:string url:string # OK
$ rake db:migrate # OK, creates table
$ ruby script/server # OK, starts WEBrick

I open up the thing in a web browser:

http://localhost:3000 # correctly shows the rails welcome splash

I navigate to

http://localhost:3000/users/new

and get a huge slew of errors:

ActiveRecord::StatementInvalid in UsersController#index

SQLite3::SQLException: no such table: users: SELECT * FROM "users" 
RAILS_ROOT: /home/drew/tracks/trunk/tracks

Application Trace | Framework Trace | Full Trace
vendor/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:188:in `log'
vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb:132:in `execute'
vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb:372:in `catch_schema_changes'
vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb:132:in `execute'
vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb:275:in `select'
vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in `select_all_without_query_cache'
vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:60:in `select_all'
vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:81:in `cache_sql'
vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:60:in `select_all'
vendor/rails/activerecord/lib/active_record/base.rb:635:in `find_by_sql'
vendor/rails/activerecord/lib/active_record/base.rb:1490:in `find_every'
vendor/rails/activerecord/lib/active_record/base.rb:589:in `find'
app/controllers/users_controller.rb:5:in `index'

wtf? Why is ruby still trying to use SQLite? database.yml has zero mention of SQLite.

Thanks

+1  A: 

Couldn't figure it out. I ended up reinstalling the OS on the VM and trying again and it worked.

FYI: Do not install rubygems from a package manager like apt-get. Compile it from source or it will all end in tears.

Drew
A: 

Quick Fix that i've used is...

When i start a project a specify the -d for database

rails -d mysql ProjectName

Which builds the database.yml file for mysql

hope this helps.

mjeason
Check the first line of code in the question.
Brock Batsell