Ruby script/console and Ruby script/server using two different DBs?
- by aronchick
Has anyone seen where script/console and script/server load two different databases (though both report using the same)? Here's the first output
$ script/server
=> Booting WEBrick
=> Rails 2.3.5 application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2010-03-21 15:54:05] INFO WEBrick 1.3.1
[2010-03-21 15:54:05] INFO ruby 1.8.7 (2010-01-10) [i386-mingw32]
[2010-03-21 15:54:05] INFO WEBrick::HTTPServer#start: pid=7148 port=3000
No errors. I then run my standard code for entering a form - no problems.
Checking the Dev Database (.yml at bottom):
mysql> select * from books;
[...]
| 712 | Book | Book Name | 2010-03-21 22:29:22 | 2010-03-21 22:29:22 |
[...]
712 rows in set (0.00 sec)
The code CLEARLY saved it seconds ago
And now here's the output of script/console:
$ script/console
Loading development environment (Rails 2.3.5)
>> Books.all
=> []
Nothing. Further, upon further inspection, it's using the production database, but I can't figure out why. Any thoughts here? All consoles have been closed and reopened.
UPDATE: Requested .yml file (can't see how it'd be helpful (user name and password are all the same for each)) -
development:
adapter: mysql
database: BooksDBdev
username: <user name>
password: <long string>
timeout: 5000
# 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: BooksDBtest
username: <user name>
password: <long string>
timeout: 5000
production:
adapter: mysql
database: BooksDB
username: <user name>
password: <long string>
timeout: 5000