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. -- Posted via http://www.ruby-forum.com/.
It must be your mysql extension. Make sure that you have native mysql extension installed. http://raa.ruby-lang.org/project/mysql-ruby/ Kent. On Wednesday 23 November 2005 09:19, Matthew Hinton wrote:> 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.
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/ > > 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 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 -- Posted via http://www.ruby-forum.com/.