views:

106

answers:

3

I'm new to Rails. I had created a Rails application earlier and also collected a few data records in the development database. Suppose, I create a new Rails application and I prefer to use the existing development database of the 1st Rails application in my newly created Rails application, how do I do that?

A: 

Just change the file config/database.yml and set the database name.

j.
In my database.yml file, I added the entire path as /var/lib/mysql/development because that is where my development database of the previous rails application is present. When I went into the directory of the new rails application and did a rake db:migrate, it gives rake aborted. Incorrect database name. I am not able to find out what is wrong with the database name. If I remove the entire path name, and just mention it as development and then run the server, it says development.locs does not exist.(Here locs is the controller name). Can someone help me find out the solution for this?
mamatha
A: 

your database.yml should look like this:

development:
  host: localhost
  adapter: mysql
  database: your_database_name [just the name, not the path]
  username: your_username
  password: your_password

test:
...

production:
...
j.
A: 

You need to change the database name in the database.yml file. The seconnd problem you run into is migrations.

I would copy the migrations form your previous application over so that you maintain migration integrity with version numbers and rolling back if that is needed.

Also, if you are seeing development.locs - that locs refers to the table_name, which in restful context is usually also coincidentally the name of the controller.

Apie