Rails: database connection


#1

I have been using rails to talk to MySQL. I followed the below tutorial
and I have been getting erros on using rake db:migrate. Could some let
me know how to resolve it.

Tutorial:
http://blog.lawrencepit.com/2008/07/19/sproutcore-rails/

Error:
srilatha-bhuvanapallis-macbook-pro:contacts Latha$ rake db:migrate
(in /Users/Latha/LearningRuby/contacts)
== CreateContacts: migrating

– create_table(:contacts)
rake aborted!
undefined method `string’ for
#ActiveRecord::ConnectionAdapters::TableDefinition:0x2289248

(See full trace by running task with --trace)

I dont see a solution to this problem. I would appreciate if someone
could provide me a solution to this.

Thanks
Latha


#2

On 2 Dec 2008, at 17:35, Srilatha Bhuvanapalli wrote:

I have been using rails to talk to MySQL. I followed the below
tutorial
and I have been getting erros on using rake db:migrate. Could some let
me know how to resolve it.

Sounds like you’re using a version of rails older than 2.0

Fred


#3

Frederick C. wrote:

On 2 Dec 2008, at 17:35, Srilatha Bhuvanapalli wrote:

I have been using rails to talk to MySQL. I followed the below
tutorial
and I have been getting erros on using rake db:migrate. Could some let
me know how to resolve it.

Sounds like you’re using a version of rails older than 2.0

Fred

My version of rails is 2.1.2
srilatha-bhuvanapallis-macbook-pro:contacts Latha$ rails -v
Rails 2.1.2


#4

On 2 Dec 2008, at 17:50, Srilatha Bhuvanapalli wrote:

Sounds like you’re using a version of rails older than 2.0

Fred

My version of rails is 2.1.2
srilatha-bhuvanapallis-macbook-pro:contacts Latha$ rails -v
Rails 2.1.2

but is that app set to use an old version of rails (eg because it’s
frozen into vendor/rails or because RAILS_GEM_VERSION is set ) ?
And of course seeing the actual code producing an error always helps.


#5

On 2 Dec 2008, at 18:04, Srilatha Bhuvanapalli wrote:

srilatha-bhuvanapallis-macbook-pro:contacts Latha$ rails -v
Rails 2.1.2

but is that app set to use an old version of rails (eg because it’s
frozen into vendor/rails or because RAILS_GEM_VERSION is set ) ?
And of course seeing the actual code producing an error always helps.

Could I please how to check if my app to set to old version of rails?

The easiest way is to run script/console or script/server - they will
tell you what version of rails is being used.


#6

Frederick C. wrote:

On 2 Dec 2008, at 17:50, Srilatha Bhuvanapalli wrote:

Sounds like you’re using a version of rails older than 2.0

Fred

My version of rails is 2.1.2
srilatha-bhuvanapallis-macbook-pro:contacts Latha$ rails -v
Rails 2.1.2

but is that app set to use an old version of rails (eg because it’s
frozen into vendor/rails or because RAILS_GEM_VERSION is set ) ?
And of course seeing the actual code producing an error always helps.

Could I please how to check if my app to set to old version of rails?

Below is my database.yml file:

MySQL (default setup). Versions 4.1 and 5.0 are recommended.

Install the MySQL driver:

gem install mysql

On MacOS X:

gem install mysql – --include=/usr/local/lib

On Windows:

gem install mysql

Choose the win32 build.

Install MySQL and put its /bin directory on your path.

And be sure to use new-style password hashing:

http://dev.mysql.com/doc/refman/5.0/en/old-client.html

development:
adapter: mysql
database: addressnote
username: root
password: changeme
socket: /tmp/mysql.sock

Warning: The database defined as ‘test’ will be erased and

re-generated from your development database when you run ‘rake’.

Do not set this db to the same as development or production.

test:
adapter: mysql
database: addressnote_test
username: root
password:
socket: /tmp/mysql.sock

production:
adapter: mysql
database: addressnote_production
username: root
password:
socket: /tmp/mysql.sock

Any help would be appreciated.

Thanks
Latha


#7

On 2 Dec 2008, at 18:15, Srilatha Bhuvanapalli wrote:

helps.

Could I please how to check if my app to set to old version of
rails?

The easiest way is to run script/console or script/server - they will
tell you what version of rails is being used.

Below is what I get when I run script/server:

It doesn’t - newer versions would tell you which already tells you
that you’re probably not running 2.1.2.
ruby script/console might still tell you (I can’t remember when they
started showing versions)

And like I said before check if your environment.rb sets
RAILS_GEM_VERSION or if vendor/rails is present.

Fred


#8

Frederick C. wrote:

On 2 Dec 2008, at 18:04, Srilatha Bhuvanapalli wrote:

srilatha-bhuvanapallis-macbook-pro:contacts Latha$ rails -v
Rails 2.1.2

but is that app set to use an old version of rails (eg because it’s
frozen into vendor/rails or because RAILS_GEM_VERSION is set ) ?
And of course seeing the actual code producing an error always helps.

Could I please how to check if my app to set to old version of rails?

The easiest way is to run script/console or script/server - they will
tell you what version of rails is being used.

Below is what I get when I run script/server:

srilatha-bhuvanapallis-macbook-pro:MyProject Latha$ ruby ./script/server
./script/…/config/boot.rb:20:Warning: Gem::SourceIndex#search support
for String patterns is deprecated
=> Booting Mongrel (use ‘script/server webrick’ to force WEBrick)
=> Rails application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
** Starting Mongrel listening at 0.0.0.0:3000
** Starting Rails with development environment…
** Rails loaded.
** Loading any Rails specific GemPlugins
** Signals ready. TERM => stop. USR2 => restart. INT => stop (no
restart).
** Rails signals registered. HUP => reload (without restart). It might
not work well.
** Mongrel 1.1.5 available at 0.0.0.0:3000
** Use CTRL-C to stop.

Where does it show me the rails version here, Sorry to bother you too
much. I am new to rails. Kindly bear with me.

Thanks
Latha


#9

Frederick C. wrote:

On 2 Dec 2008, at 18:15, Srilatha Bhuvanapalli wrote:

helps.

Could I please how to check if my app to set to old version of
rails?

The easiest way is to run script/console or script/server - they will
tell you what version of rails is being used.

Below is what I get when I run script/server:

It doesn’t - newer versions would tell you which already tells you
that you’re probably not running 2.1.2.
ruby script/console might still tell you (I can’t remember when they
started showing versions)

And like I said before check if your environment.rb sets
RAILS_GEM_VERSION or if vendor/rails is present.

Fred

hey,

thanks a lot. that helped me. my applications RAILS_GEMS_VERSION was set
to 1.2.6. I made the change to 2.1.2 and it worked.

Thanks a lot
Latha