What's the difference between just firing up a rails console with script/console and a rails console in sandbox mode with script/console --sandbox.
+5
A:
In sandbox mode, any database changes made while in the console will be reverted when you exit the console.
This is different to the regular console where all database changes will remain when you exit.
Parker McGee
2010-07-27 04:14:17
So you can make changes to the database when you're not in sandbox mode? I guess I don't understand why you would ever want to do this. I could see how you might want to do something like add a new user for testing purposes in the development environment, but what else would you use it for?
Lee McAlilly
2010-07-28 03:38:49
Related to this, let's say you define a method in the console. If you do this without sandbox turned on, is that method then available in your app, or does it disappear when you exit the console. That may be a dumb question, but I'm trying to understand how the console interacts with the app.
Lee McAlilly
2010-07-28 03:58:26
Sandbox mode only relates to the database, so no, methods created in a non-sandboxed console will not be accessible to the application. Non-sandbox mode is useful when you actually want to make database changes. I use it sometimes in my production environment when I want to make a user an administrator. Since it's such an infrequent action, it was a waste to make a whole interface to do it, but it's nice to be able to do every once in a while via the console.
Parker McGee
2010-07-28 05:41:26
Thanks, that makes sense now.
Lee McAlilly
2010-07-28 18:59:13