This project is archived and is in readonly mode.
Rails3: observer in config/application.rb brokes rake db:migrate
-
Santiago Pastorino
- Tag changed from rails3 observers to arel rails3, rails3 observers, migrations
- State changed from new to open
- Milestone cleared.
- Importance changed from to Low
I've reproduced this
-
Santiago Pastorino
I'm thinking that we need to execute build_* things on ARel just before executing the query.
Also this is going to improve a lot the performance because of the way the current code is cloning every Arel::Relation object just before execute each method.
So perhaps keeping a trace of what to do and do at the end on build_arel and then execute the query i think it would be the best and a solution for that. -
Jeremy Kemper
Workaround:
def self.old() where :status => 'old' endThe root fix is as Santiago suggests: building the relation should be lazy, not loading the table until SQL is actually needed.
-
Michael Koziarski
Alternative work around:
scope :old, lambda { where(:status => "old") } -
Santiago Pastorino
Another one :P
config.active_record.observers = :order_observer unless File.basename($0) == 'rake' -
José Valim
- Importance changed from Low to High
Sometime ago we had the same issue and this commit fixed it:
http://github.com/rails/rails/commit/181c414baa877d748671d03fb09499...
It seems that something else is causing the same failure. My suggestion is:
-
Implement the behavior described in the TODO in the commit above, to ensure we won't have other leakage;
-
Add a test to railtie suite;
Notice, that the observer just trigger the model to be loaded earlier triggering the issue. If you are using a plugin that forces all your models to be loaded or an initializer, the same issue would appear (as stated in #5003).
-
Repository
(from [67582f08bf86ec71a27363554bc550e929a007f7]) Push a failing test for issues [#4994] and [#5003]. http://github.com/rails/rails/commit/67582f08bf86ec71a27363554bc550...
-
Repository
- State changed from open to resolved
(from [af6ec607fa9af96569fd2e143147f2dc0ecd583b]) No need to check if the attribute exists (this is the same behavior as in 2.3) [#4994 state:resolved] and [#5003 state:resolved] http://github.com/rails/rails/commit/af6ec607fa9af96569fd2e143147f2...