What DB does rails 3 console --sandbox use?

console, ruby-on-rails, ruby-on-rails-3.2

Solution

Because the console acts as one big transaction in sandbox mode, you can see inserts you make only through the console.

If you are connecting to your db through any other method than the console, then it will be using a different connection and the things the console is doing will be hidden from that connection because they are not yet committed.

When a connection talks to a database using a transaction, other database connections can't see any changes it makes until it commits. The connection with the transaction (in this case, the sandboxed console) is the only connection that can see the changes it makes to the database before rollback.

Problem

when I run "rails console --sandbox" I am not able to see inserts in my database. When I leave the option off I am able to see the data in my development database just fine. Everything from the console seems to work the same. I am using postgreSQL as set up in Hartl's rails tutorial. I have looked in each of the databases, Development, Test, Postgres. But cannot find the data I created using the console. As I am using bundel, I tried with and with out "bundle exec" Here is my database.yml: ``` development: adapter: postgresql encoding: unicode database: sample_app_development pool: 5 timeout: 5000 username: user password: test: adapter: postgresql encoding: unicode database: sample_app_test pool: 5 timeout: 5000 username: user password: ``` I suppose this is not critical but I am just very curious what is happening under the covers here. Thanks, Mark

Original source

Related problems