diff options
-rw-r--r-- | railties/CHANGELOG | 2 | ||||
-rw-r--r-- | railties/bin/console | 23 | ||||
-rw-r--r-- | railties/lib/rails_generator/generators/applications/app/app_generator.rb | 2 |
3 files changed, 23 insertions, 4 deletions
diff --git a/railties/CHANGELOG b/railties/CHANGELOG index 8bea71c1a2..2182dbc716 100644 --- a/railties/CHANGELOG +++ b/railties/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Added --sandbox option to script/console that'll roll back all changes made to the database when you quit #672 [bitsweat] + * Added 'recent' as a rake target that'll run tests for files that changed in the last 10 minutes #612 [bitsweat] * Changed script/console to default to development environment and drop --no-inspect #650 [bitsweat] diff --git a/railties/bin/console b/railties/bin/console index a946d1a08a..fa7acc1598 100644 --- a/railties/bin/console +++ b/railties/bin/console @@ -1,5 +1,22 @@ #!/usr/local/bin/ruby -ENV['RAILS_ENV'] = ARGV[0] || 'development' -puts "Loading environment: #{ENV['RAILS_ENV']}" irb = RUBY_PLATFORM =~ /mswin32/ ? 'irb.bat' : 'irb' -exec "#{irb} -r config/environment.rb -r irb/completion" + +require 'optparse' +options = {} +OptionParser.new do |opt| + opt.on('-s', '--sandbox', 'Rollback database modifications on exit.') { |options[:sandbox]| } + opt.parse!(ARGV) +end + +libs = " -r #{File.dirname(__FILE__)}/../config/environment" +libs << " -r #{File.dirname(__FILE__)}/console_sandbox" if options[:sandbox] +libs << " -r irb/completion" + +ENV['RAILS_ENV'] = ARGV.first || 'development' +if options[:sandbox] + puts "Loading #{ENV['RAILS_ENV']} environment in sandbox." + puts "Any modifications you make will be rolled back on exit." +else + puts "Loading #{ENV['RAILS_ENV']} environment." +end +exec "#{irb} #{libs}" diff --git a/railties/lib/rails_generator/generators/applications/app/app_generator.rb b/railties/lib/rails_generator/generators/applications/app/app_generator.rb index bf29240908..8bdc6db86b 100644 --- a/railties/lib/rails_generator/generators/applications/app/app_generator.rb +++ b/railties/lib/rails_generator/generators/applications/app/app_generator.rb @@ -47,7 +47,7 @@ class AppGenerator < Rails::Generator::Base m.file "environments/test.rb", "config/environments/test.rb" # Scripts - %w(console destroy generate server).each do |file| + %w(console console_sandbox.rb destroy generate server).each do |file| m.file "bin/#{file}", "script/#{file}", script_options end if options[:gem] |