Unable to change the database

Hi All,

  I have started to learn RoR couple of days back. I am using Aptana editor for Rails.

  I created a new project called users and the database called users_development. I have added the controller called which is working. Now I am trying to change the DB from users_development to scraping_development. I edited the database.yml file from users_development to scraping_development. Now I tried to run my login controller. But it is not running it is throwing an error saying that 'Unknown database scraping_development'.

   Can somebody please help me to resolve this problem. I am totally halted with this problem..

Thanks, Ramu.

Hey Ram,

One YML can hook one DB only.In order to commnicate with Multiple DB’s U need to use Establish_connection of Active Record.

  • RajKishan

I want to change the Db from users_development to scraping_development. I dont want my application point to 2 databases. I want to connet to scraping_development only. Can you please reply me how I can do that??

cool.Do like this

Forst Specify users_development in DataBase.yml

and in the Model or any where you want to Use 2nd DB please try with establish_connection() for 2nd DB.I know i am confucing you a bit please read here you will get an idea.

http://scour.com/view/result/?URL=http://api.rubyonrails.org/classes/ActiveRecord/Base.html

and read for that method.I hope this would help.

  • RajKishan

I am not able to see any thing in the below link??

and I have one more question. anyway I am not going to use database "users_development" so why should not I remove the DB entry from the database.yml file???

Could you please help me in this?? I am helpless

I thought you were working on Distributed DB’s.

Then Remove it from YML and place new one.Very simple.

I did the same it is not working. It is saying Unknown database

Which DB you are Using ? Is it MYSQL probably Adapter needs to be changed from default sqlLite to Mysql

I am using mysql and the 2 DBs are there in mysql only

Hey Check probably DB name had a Typo :frowning:

RAMU wrote:

  I created a new project called users and the database called users_development. I have added the controller called which is working. Now I am trying to change the DB from users_development to scraping_development. I edited the database.yml file from users_development to scraping_development. Now I tried to run my login controller. But it is not running it is throwing an error saying that 'Unknown database scraping_development'.

It is correctly telling you the mysqld (which is outside the editor) has no database with that name.

I often create new databases with this magical hack:

   echo create database scraping_development\; | mysql -u root

If that causes any trouble, just run mysql -u root (or a graphical mysql administrator) to create a database with that name.

Rajeshwar Mothe wrote:

and in the Model or any where you want to Use 2nd DB please try with establish_connection() for 2nd DB.I know i am confucing you a bit please read here you will get an idea.

Please read the question again!