# RoR Not Selecting Database

**URL:** <https://www.ruby-forum.com/t/ror-not-selecting-database/48691>\
**Category:** Rails\
**Created:** [November 23, 2005, 3:19pm UTC](https://www.ruby-forum.com/t/ror-not-selecting-database/48691 "2005-11-23T15:19:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mhinton](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/8edcca/32.png) [@mhinton](https://www.ruby-forum.com/u/mhinton)\
**Post date:** [November 23, 2005, 3:19pm UTC](https://www.ruby-forum.com/t/ror-not-selecting-database/48691/1 "2005-11-23T15:19:33Z")

</div>

I am trying to setup RoR and I appear to have everything setup  
correctly but I am getting a db error. I am on Mac OS X and I am using  
MySQL 5 for my database. I setup my database.yml and my model and  
controller. I can put an index method in my controller and display  
some text. When I replace my index method with

model :recipe  
scaffold :recipe

I get an ActiveRecord::InvalidStatement error. No database selected  
when rails trys to run the “SELECT COUNT(\*) FROM recipes” query.

In my MySQL query log I can see the “SELECT COUNT(\*) FROM recipes”  
query so connecting to the database is no problem. It seems like rails  
isn’t issuing a “use recipes” statement before issuing the query. I  
spent an entire day trying to get everything setup correctly over the  
weekend and I am stumped as to how to fix this.

Any help would be greatly appreciated thanks.

---

<div class="post-metadata">

**Author:** ![mhinton](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/8edcca/32.png) [@mhinton](https://www.ruby-forum.com/u/mhinton)\
**Post date:** [November 25, 2005, 5:00am UTC](https://www.ruby-forum.com/t/ror-not-selecting-database/48691/2 "2005-11-25T05:00:26Z")

</div>

It must be your mysql extension. Make sure that you have native mysql  
extension installed.

[http://raa.ruby-lang.org/project/mysql-ruby/](http://raa.ruby-lang.org/project/mysql-ruby/)

Kent.

---

<div class="post-metadata">

**Author:** ![mhinton](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/8edcca/32.png) [@mhinton](https://www.ruby-forum.com/u/mhinton)\
**Post date:** [November 26, 2005, 9:00pm UTC](https://www.ruby-forum.com/t/ror-not-selecting-database/48691/3 "2005-11-26T21:00:52Z")

</div>

ksibilev wrote:

> It must be your mysql extension. Make sure that you have native mysql  
> extension installed.
> 
> [http://raa.ruby-lang.org/project/mysql-ruby/](http://raa.ruby-lang.org/project/mysql-ruby/)
> 
> Kent.

I issued the following command and got the following output and I still  
have the same problem.

Matt@Bender:~$ sudo gem install mysql – --with-mysql-config  
Password:  
Attempting local installation of ‘mysql’  
Local gem file not found: mysql\*.gem  
Attempting remote installation of ‘mysql’  
Updating Gem source index for: [http://gems.rubyforge.org](http://gems.rubyforge.org)  
Building native extensions. This could take a while…  
In file included from mysql.c:5:  
/usr/lib/ruby/1.8/powerpc-darwin8.0/ruby.h:74:3: error: #error ----\>\>  
ruby requires sizeof(void\*) == sizeof(long) to be compiled. \<\<----  
/usr/lib/ruby/1.8/powerpc-darwin8.0/ruby.h:670:21: error: missing.h: No  
such file or directory  
/usr/lib/ruby/1.8/powerpc-darwin8.0/ruby.h:671:20: error: intern.h: No  
such file or directory  
In file included from mysql.c:5:  
/usr/lib/ruby/1.8/powerpc-darwin8.0/ruby.h:682: error: parse error  
before ‘rb\_nativethread\_t’  
/usr/lib/ruby/1.8/powerpc-darwin8.0/ruby.h:682: warning: data definition  
has no type or storage class  
mysql.c:6:21: error: version.h: No such file or directory  
make: \*\*\* [mysql.o] Error 1  
In file included from mysql.c:5:  
/usr/lib/ruby/1.8/powerpc-darwin8.0/ruby.h:74:3: error: #error ----\>\>  
ruby requires sizeof(void\*) == sizeof(long) to be compiled. \<\<----  
/usr/lib/ruby/1.8/powerpc-darwin8.0/ruby.h:670:21: error: missing.h: No  
such file or directory  
/usr/lib/ruby/1.8/powerpc-darwin8.0/ruby.h:671:20: error: intern.h: No  
such file or directory  
In file included from mysql.c:5:  
/usr/lib/ruby/1.8/powerpc-darwin8.0/ruby.h:682: error: parse error  
before ‘rb\_nativethread\_t’  
/usr/lib/ruby/1.8/powerpc-darwin8.0/ruby.h:682: warning: data definition  
has no type or storage class  
mysql.c:6:21: error: version.h: No such file or directory  
make: \*\*\* [mysql.o] Error 1  
ruby extconf.rb install mysql – --with-mysql-config  
checking for mysql\_ssl\_set()… yes  
checking for mysql.h… yes  
creating Makefile

make  
gcc -fno-common -arch ppc -g -Os -pipe -fno-common -arch ppc -pipe  
-pipe -fno-common -I. -I/usr/lib/ruby/1.8/powerpc-darwin8.0  
-I/usr/lib/ruby/1.8/powerpc-darwin8.0 -I. -DHAVE\_MYSQL\_SSL\_SET  
-DHAVE\_MYSQL\_H -I/usr/local/mysql/include -Os -arch ppc -fno-common -c  
mysql.c

make install  
gcc -fno-common -arch ppc -g -Os -pipe -fno-common -arch ppc -pipe  
-pipe -fno-common -I. -I/usr/lib/ruby/1.8/powerpc-darwin8.0  
-I/usr/lib/ruby/1.8/powerpc-darwin8.0 -I. -DHAVE\_MYSQL\_SSL\_SET  
-DHAVE\_MYSQL\_H -I/usr/local/mysql/include -Os -arch ppc -fno-common -c  
mysql.c  
Successfully installed mysql-2.7
