Whilst it is asking for trouble, many developers (myself included) cannot 
resist the occasional temptation to drop into a Rails console in a 
production environment and perform data mods on production data.

In the spirit of the current "sandbox" option available in the Rails 
console, what do you think about another option that offers a "protected" 
session, in which:

   - Like "sandbox", the console session is wrapped in a database 
   transaction, but
   - At the end of the session changes are listed (either summarily in # of 
   changes, or in listed detail) and can be committed or rolled back by "y/n" 
   confirmation

Why? 

In addition to protecting against ruining production data, it would allow 
people to inspect and validate the effect of their data mod on production 
data without having to apply a DB-wide restore from a backup if a mistake 
is made or changes aren't what they expect.

The test case in `console_test.rb` might look like:



  def test_protected
    spawn_console


    write_prompt "Post.count", "=> 0"
    write_prompt "Post.create"
    write_prompt "Post.count", "=> 1"


    @master.puts "quit"


    assert_output "Commit 1 change? (y/n)"


    @master.puts "n"


    spawn_console


    write_prompt "Post.count", "=> 0"
    write_prompt "Post.create"
    write_prompt "Post.create"
    write_prompt "Post.count", "=> 2"


    @master.puts "quit"


    assert_output "Commit 2 changes? (y/n)"


    @master.puts "y"


    spawn_console


    write_prompt "Post.count", "=> 2"
  end






-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

Reply via email to