lib/rails/commands/runner.rb in railties-3.1.0.beta1 vs lib/rails/commands/runner.rb in railties-3.1.0.rc1

- old
+ new

@@ -23,11 +23,11 @@ opts.separator "" opts.separator "You can also use runner as a shebang line for your scripts like this:" opts.separator "-------------------------------------------------------------" opts.separator "#!/usr/bin/env #{File.expand_path($0)} runner" opts.separator "" - opts.separator "Product.find(:all).each { |p| p.price *= 2 ; p.save! }" + opts.separator "Product.all.each { |p| p.price *= 2 ; p.save! }" opts.separator "-------------------------------------------------------------" end opts.order! { |o| code_or_file ||= o } rescue retry end @@ -37,20 +37,14 @@ ENV["RAILS_ENV"] = options[:environment] require APP_PATH Rails.application.require_environment! -begin - if code_or_file.nil? - $stderr.puts "Run '#{$0} -h' for help." - exit 1 - elsif File.exist?(code_or_file) - $0 = code_or_file - eval(File.read(code_or_file), nil, code_or_file) - else - eval(code_or_file) - end -ensure - if defined? Rails - Rails.logger.flush if Rails.logger.respond_to?(:flush) - end +if code_or_file.nil? + $stderr.puts "Run '#{$0} -h' for help." + exit 1 +elsif File.exist?(code_or_file) + $0 = code_or_file + eval(File.read(code_or_file), nil, code_or_file) +else + eval(code_or_file) end