1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #5995 from kennyj/fix_5847-3

Fix #5847 and #4045. Load AR::Base before loading an application model.
This commit is contained in:
Jon Leighton 2012-04-26 06:11:00 -07:00
commit 8cd14c0bc9
2 changed files with 27 additions and 0 deletions

View file

@ -128,5 +128,10 @@ module ActiveRecord
end
end
config.after_initialize do
# We should load ActiveRecord::Base class before loading an application model.
require "active_record/base"
end
end
end

View file

@ -167,5 +167,27 @@ module ApplicationTests
end
assert !File.exists?(File.join(app_path, 'db', 'schema_cache.dump'))
end
def test_load_activerecord_base_when_we_use_observers
Dir.chdir(app_path) do
`bundle exec rails g model user;
bundle exec rake db:migrate;
bundle exec rails g observer user;`
add_to_config "config.active_record.observers = :user_observer"
assert_equal "0", `bundle exec rails r "puts User.count"`.strip
app_file "lib/tasks/count_user.rake", <<-RUBY
namespace :user do
task :count => :environment do
puts User.count
end
end
RUBY
assert_equal "0", `bundle exec rake user:count`.strip
end
end
end
end