From 4e4bcb4c6b08ed392cd5576dcfc252ef574a1b88 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sat, 31 May 2008 14:54:17 -0700 Subject: Ruby 1.8.7 compat: TimeWithZone# and Chars#respond_to? pass along the include_private argument --- activesupport/lib/active_support/multibyte/chars.rb | 12 +++++++----- activesupport/lib/active_support/time_with_zone.rb | 8 ++++---- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/activesupport/lib/active_support/multibyte/chars.rb b/activesupport/lib/active_support/multibyte/chars.rb index ee716de39e..185d03020c 100644 --- a/activesupport/lib/active_support/multibyte/chars.rb +++ b/activesupport/lib/active_support/multibyte/chars.rb @@ -40,13 +40,15 @@ module ActiveSupport::Multibyte #:nodoc: # core dumps. Don't go there. @string end - + # Make duck-typing with String possible - def respond_to?(method) - super || @string.respond_to?(method) || handler.respond_to?(method) || - (method.to_s =~ /(.*)!/ && handler.respond_to?($1)) || false + def respond_to?(method, include_priv = false) + super || @string.respond_to?(method, include_priv) || + handler.respond_to?(method, include_priv) || + (method.to_s =~ /(.*)!/ && handler.respond_to?($1, include_priv)) || + false end - + # Create a new Chars instance. def initialize(str) @string = str.respond_to?(:string) ? str.string : str diff --git a/activesupport/lib/active_support/time_with_zone.rb b/activesupport/lib/active_support/time_with_zone.rb index ece95eeae9..bfc5b16039 100644 --- a/activesupport/lib/active_support/time_with_zone.rb +++ b/activesupport/lib/active_support/time_with_zone.rb @@ -248,14 +248,14 @@ module ActiveSupport def marshal_load(variables) initialize(variables[0], ::Time.send!(:get_zone, variables[1]), variables[2]) end - + # Ensure proxy class responds to all methods that underlying time instance responds to. - def respond_to?(sym) + def respond_to?(sym, include_priv = false) # consistently respond false to acts_like?(:date), regardless of whether #time is a Time or DateTime return false if sym.to_s == 'acts_like_date?' - super || time.respond_to?(sym) + super || time.respond_to?(sym, include_priv) end - + # Send the missing method to +time+ instance, and wrap result in a new TimeWithZone with the existing +time_zone+. def method_missing(sym, *args, &block) result = time.__send__(sym, *args, &block) -- cgit v1.2.3 From 0abf0da0016abc455145810d7060a10e0b56b0b6 Mon Sep 17 00:00:00 2001 From: Michael Koziarski Date: Sat, 31 May 2008 14:58:34 -0700 Subject: Don't provide the password with dbconsole unless explicitly opted in. Some operating system configurations allow other users to view your process list or environmental variables. This option should not be used on shared hosts. http://dev.mysql.com/doc/refman/5.0/en/password-security.html http://www.postgresql.org/docs/8.3/static/libpq-envars.html --- railties/lib/commands/dbconsole.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/railties/lib/commands/dbconsole.rb b/railties/lib/commands/dbconsole.rb index b81997aa59..17acb7b68f 100644 --- a/railties/lib/commands/dbconsole.rb +++ b/railties/lib/commands/dbconsole.rb @@ -2,8 +2,13 @@ require 'erb' require 'yaml' require 'optparse' +include_password = false + OptionParser.new do |opt| - opt.banner = "Usage: dbconsole [environment]" + opt.banner = "Usage: dbconsole [options] [environment]" + opt.on("-p", "--include-password", "Automatically provide the database from database.yml") do |v| + include_password = true + end opt.parse!(ARGV) abort opt.to_s unless (0..1).include?(ARGV.size) end @@ -31,10 +36,13 @@ when "mysql" 'port' => '--port', 'socket' => '--socket', 'username' => '--user', - 'password' => '--password', 'encoding' => '--default-character-set' }.map { |opt, arg| "#{arg}=#{config[opt]}" if config[opt] }.compact + if config['password'] && include_password + args << "--password=#{config['password']}" + end + args << config['database'] exec(find_cmd('mysql5', 'mysql'), *args) @@ -43,7 +51,7 @@ when "postgresql" ENV['PGUSER'] = config["username"] if config["username"] ENV['PGHOST'] = config["host"] if config["host"] ENV['PGPORT'] = config["port"].to_s if config["port"] - ENV['PGPASSWORD'] = config["password"].to_s if config["password"] + ENV['PGPASSWORD'] = config["password"].to_s if config["password"] && include_password exec(find_cmd('psql'), config["database"]) when "sqlite" -- cgit v1.2.3 From 3a9775076fc4f99f8d7ad9a554a9ef8798c8fad7 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Sat, 31 May 2008 15:32:51 -0700 Subject: Removed suggestion for turning off partial updates. --- railties/environments/environment.rb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/railties/environments/environment.rb b/railties/environments/environment.rb index 468fa45ef6..a85ade371b 100644 --- a/railties/environments/environment.rb +++ b/railties/environments/environment.rb @@ -64,7 +64,4 @@ Rails::Initializer.run do |config| # Activate observers that should always be running # config.active_record.observers = :cacher, :garbage_collector - - # Make ActiveRecord only save the attributes that have changed since the record was loaded. - # config.active_record.partial_updates = true -end \ No newline at end of file +end -- cgit v1.2.3 From 7391f7728d96c2ec0113de57f3316c191043ad2c Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sat, 31 May 2008 15:31:04 -0700 Subject: Ruby 1.8.7 compat: work around broken DelegateClass#respond_to? --- actionpack/lib/action_controller/cgi_ext/cookie.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/actionpack/lib/action_controller/cgi_ext/cookie.rb b/actionpack/lib/action_controller/cgi_ext/cookie.rb index ef033fb4f3..009ddd1c64 100644 --- a/actionpack/lib/action_controller/cgi_ext/cookie.rb +++ b/actionpack/lib/action_controller/cgi_ext/cookie.rb @@ -78,6 +78,12 @@ class CGI #:nodoc: buf end + # FIXME: work around broken 1.8.7 DelegateClass#respond_to? + def respond_to?(method, include_private = false) + return true if super(method) + return __getobj__.respond_to?(method, include_private) + end + # Parses a raw cookie string into a hash of cookie-name => cookie-object # pairs. # -- cgit v1.2.3 From 9b75483bf361f44046d1cb86bd2acae6c4f856f3 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sat, 31 May 2008 15:51:01 -0700 Subject: Added better error message for when the class name is already used (and dont show suggestions if there are none) --- railties/lib/rails_generator/commands.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/railties/lib/rails_generator/commands.rb b/railties/lib/rails_generator/commands.rb index 03b7d354a6..08ecbfb5cf 100644 --- a/railties/lib/rails_generator/commands.rb +++ b/railties/lib/rails_generator/commands.rb @@ -380,12 +380,14 @@ HELP # Thanks to Florian Gross (flgr). def raise_class_collision(class_name) message = <