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)
>> Book.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
Updated 2: Here's the outp开发者_Go百科ut when I force the console environment.
$ script/console development
Loading development environment (Rails 2.3.5)
>> Book.all
=> []
>> exit
$ ruby script/console development
Loading development environment (Rails 2.3.5)
>> Book.all
=> []
Just FYI, I don't have RAILS_ENV specified in my environment variables.
Are you running these at the same time, in different terminals? If so, you may need to do reload!
in your console for the database changes to show up.
Pluralized model name? Yikes! Do you have another model called Book or something?
精彩评论