aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/rails/generators/active_record/model/model_generator.rb18
-rw-r--r--activerecord/test/cases/migration_test.rb1
2 files changed, 9 insertions, 10 deletions
diff --git a/activerecord/lib/rails/generators/active_record/model/model_generator.rb b/activerecord/lib/rails/generators/active_record/model/model_generator.rb
index e4c9539362..15aecf28ca 100644
--- a/activerecord/lib/rails/generators/active_record/model/model_generator.rb
+++ b/activerecord/lib/rails/generators/active_record/model/model_generator.rb
@@ -29,25 +29,25 @@ module ActiveRecord
template 'module.rb', File.join('app/models', "#{class_path.join('/')}.rb") if behavior == :invoke
end
- def attributes_with_index
- attributes.select { |a| !a.reference? && a.has_index? }
- end
-
- def accessible_attributes
- attributes.reject(&:reference?)
- end
-
hook_for :test_framework
protected
+ def attributes_with_index
+ attributes.select { |a| !a.reference? && a.has_index? }
+ end
+
# Used by the migration template to determine the parent name of the model
def parent_class_name
options[:parent] || determine_default_parent_class
end
def determine_default_parent_class
- if File.exist?('app/models/application_record.rb')
+ application_record = nil
+
+ in_root { application_record = File.exist?('app/models/application_record.rb') }
+
+ if application_record
"ApplicationRecord"
else
"ActiveRecord::Base"
diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb
index 19be357b6e..b6813891c6 100644
--- a/activerecord/test/cases/migration_test.rb
+++ b/activerecord/test/cases/migration_test.rb
@@ -549,7 +549,6 @@ class MigrationTest < ActiveRecord::TestCase
expected_id = Zlib.crc32(current_database) * salt
assert lock_id == expected_id, "expected lock id generated by the migrator to be #{expected_id}, but it was #{lock_id} instead"
- assert lock_id.is_a?(Fixnum), "expected lock id to be a Fixnum, but it wasn't"
assert lock_id.bit_length <= 63, "lock id must be a signed integer of max 63 bits magnitude"
end