diff options
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/activerecord.gemspec | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/base.rb | 16 | ||||
-rw-r--r-- | activerecord/lib/active_record/railties/databases.rake | 3 | ||||
-rw-r--r-- | activerecord/test/cases/attribute_methods_test.rb | 8 |
4 files changed, 20 insertions, 9 deletions
diff --git a/activerecord/activerecord.gemspec b/activerecord/activerecord.gemspec index 43a1258c20..b7e23faa09 100644 --- a/activerecord/activerecord.gemspec +++ b/activerecord/activerecord.gemspec @@ -13,7 +13,7 @@ Gem::Specification.new do |s| s.email = 'david@loudthinking.com' s.homepage = 'http://www.rubyonrails.org' - s.files = Dir['CHANGELOG', 'README.rdoc', 'examples/**/*', 'lib/**/*'] + s.files = Dir['CHANGELOG', 'MIT-LICENSE', 'README.rdoc', 'examples/**/*', 'lib/**/*'] s.require_path = 'lib' s.extra_rdoc_files = %w( README.rdoc ) diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index f6a80b8bce..f74810720d 100644 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -1857,12 +1857,16 @@ MSG # Returns the contents of the record as a nicely formatted string. def inspect - attributes_as_nice_string = self.class.column_names.collect { |name| - if has_attribute?(name) - "#{name}: #{attribute_for_inspect(name)}" - end - }.compact.join(", ") - "#<#{self.class} #{attributes_as_nice_string}>" + inspection = if @attributes + self.class.column_names.collect { |name| + if has_attribute?(name) + "#{name}: #{attribute_for_inspect(name)}" + end + }.compact.join(", ") + else + "not initialized" + end + "#<#{self.class} #{inspection}>" end protected diff --git a/activerecord/lib/active_record/railties/databases.rake b/activerecord/lib/active_record/railties/databases.rake index 2c7298e220..6f8f84d50b 100644 --- a/activerecord/lib/active_record/railties/databases.rake +++ b/activerecord/lib/active_record/railties/databases.rake @@ -481,8 +481,7 @@ db_namespace = namespace :db do # desc "Creates a sessions migration for use with ActiveRecord::SessionStore" task :create => :environment do raise 'Task unavailable to this database (no migration support)' unless ActiveRecord::Base.connection.supports_migrations? - require 'rails/generators' - Rails::Generators.configure! + Rails.application.load_generators require 'rails/generators/rails/session_migration/session_migration_generator' Rails::Generators::SessionMigrationGenerator.start [ ENV['MIGRATION'] || 'add_sessions_table' ] end diff --git a/activerecord/test/cases/attribute_methods_test.rb b/activerecord/test/cases/attribute_methods_test.rb index 5074ae50ab..54c4d4ae90 100644 --- a/activerecord/test/cases/attribute_methods_test.rb +++ b/activerecord/test/cases/attribute_methods_test.rb @@ -109,6 +109,14 @@ class AttributeMethodsTest < ActiveRecord::TestCase assert_respond_to topic, :title end + # IRB inspects the return value of "MyModel.allocate" + # by inspecting it. + def test_allocated_object_can_be_inspected + topic = Topic.allocate + assert_nothing_raised { topic.inspect } + assert topic.inspect, "#<Topic not initialized>" + end + def test_array_content topic = Topic.new topic.content = %w( one two three ) |