mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fixed dependency reloading by switching to a remove_const approach where all Active Records, Active Record Observers, and Action Controllers are reloading by undefining their classes. This enables you to remove methods in all three types and see the change reflected immediately and it fixes #539. This also means that only those three types of classes will benefit from the const_missing and reloading approach. If you want other classes (like some in lib/) to reload, you must use require_dependency to do it.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@511 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
11611c1b00
commit
10220d356d
3 changed files with 17 additions and 20 deletions
14
activerecord/test/association_inheritance_reload.rb
Normal file
14
activerecord/test/association_inheritance_reload.rb
Normal file
|
@ -0,0 +1,14 @@
|
|||
require 'abstract_unit'
|
||||
require 'fixtures/company'
|
||||
|
||||
class AssociationInheritanceReloadTest < Test::Unit::TestCase
|
||||
fixtures :companies
|
||||
|
||||
def test_set_attributes
|
||||
assert_equal ["errors.add_on_empty('name', \"can't be empty\")"], Firm.read_inheritable_attribute("validate"), "Second run"
|
||||
# ActiveRecord::Base.reset_column_information_and_inheritable_attributes_for_all_subclasses
|
||||
remove_subclass_of(ActiveRecord::Base)
|
||||
load 'fixtures/company.rb'
|
||||
assert_equal ["errors.add_on_empty('name', \"can't be empty\")"], Firm.read_inheritable_attribute("validate"), "Second run"
|
||||
end
|
||||
end
|
4
activerecord/test/fixtures/company.rb
vendored
4
activerecord/test/fixtures/company.rb
vendored
|
@ -12,10 +12,10 @@ class Firm < Company
|
|||
has_many :clients_like_ms, :conditions => "name = 'Microsoft'", :class_name => "Client", :order => "id"
|
||||
has_many :clients_using_sql, :class_name => "Client", :finder_sql => 'SELECT * FROM companies WHERE client_of = #{id}'
|
||||
has_many :clients_using_counter_sql, :class_name => "Client",
|
||||
:finder_sql => 'SELECT * FROM companies WHERE client_of = #{id}',
|
||||
:finder_sql => 'SELECT * FROM companies WHERE client_of = #{id}',
|
||||
:counter_sql => 'SELECT COUNT(*) FROM companies WHERE client_of = #{id}'
|
||||
has_many :clients_using_zero_counter_sql, :class_name => "Client",
|
||||
:finder_sql => 'SELECT * FROM companies WHERE client_of = #{id}',
|
||||
:finder_sql => 'SELECT * FROM companies WHERE client_of = #{id}',
|
||||
:counter_sql => 'SELECT 0 FROM companies WHERE client_of = #{id}'
|
||||
|
||||
has_one :account, :dependent => true
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
*SVN*
|
||||
|
||||
* Fixed that /Recipe/new and /recipe/new points to the same thing [Lyle Johnson]
|
||||
* Fixed dependency reloading by switching to a remove_const approach where all Active Records, Active Record Observers, and Action Controllers are reloading by undefining their classes. This enables you to remove methods in all three types and see the change reflected immediately and it fixes #539. This also means that only those three types of classes will benefit from the const_missing and reloading approach. If you want other classes (like some in lib/) to reload, you must use require_dependency to do it.
|
||||
|
||||
* Added Florian Gross' latest version of Breakpointer and friends that fixes a variaty of bugs #441 [Florian Gross]
|
||||
|
||||
|
@ -8,23 +8,6 @@
|
|||
|
||||
* Fixed that script/breakpointer didn't get the Ruby path rewritten as the other scripts #523 [brandt@kurowski.net]
|
||||
|
||||
* Fixed superclass mismatch and other controller related problems by not using dependency reloading for controllers. This means that controller
|
||||
hierarchies need to explicitly require the superclass if its not ApplicationController. Example:
|
||||
|
||||
# application.rb
|
||||
class ApplicationController < ActionController::Base
|
||||
end
|
||||
|
||||
# base.rb
|
||||
class BaseController < ApplicationController
|
||||
end
|
||||
|
||||
# media_controller.rb
|
||||
require_or_load 'base'
|
||||
class MediaController < BaseController
|
||||
end
|
||||
|
||||
|
||||
* Fixed handling of syntax errors in models that had already been succesfully required once in the current interpreter
|
||||
|
||||
* Fixed that models that weren't referenced in associations weren't being reloaded in the development mode by reinstating the reload
|
||||
|
|
Loading…
Reference in a new issue