Hi ! I have a little problem here. r3169, "Enable warnings on first load only. File which are loaded but raise an exception are not added to loaded set" http://dev.rubyonrails.org/changeset/3169 causes stack level too deep errors while loading my models, using the console. $ svn up -r3169 vendor\rails At revision 3169. $ ruby script\console Loading development environment.>> GreenbackTransaction.newSystemStackError: stack level too deep from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/inflector.rb:121:in `underscore' from ./script/../config/../config/../vendor/rails/activerecord/lib/active_record/associations.rb:780:in `require_association_class' from ./script/../config/../config/../vendor/rails/activerecord/lib/active_record/associations.rb:355:in `has_many_without_reflection' from (eval):5:in `has_many' from ./script/../config/../config/../app/models/greenback_transaction.rb:2 from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:228:in `load' from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:228:in `load' from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:52:in `require_or_load' from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:52:in `enable_warnings' from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:52:in `require_or_load' from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:28:in `depend_on' from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:36:in `associate_with' from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:200:in `require_association' from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:200:in `require_association' from ./script/../config/../config/../vendor/rails/activerecord/lib/active_record/associations.rb:780:in `require_association_class' from ./script/../config/../config/../vendor/rails/activerecord/lib/active_record/associations.rb:524:in `belongs_to_without_reflection' ... 945 levels... from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:200:in `require_association' from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:200:in `require_association' from ./script/../config/../config/../vendor/rails/activerecord/lib/active_record/associations.rb:780:in `require_association_class' from ./script/../config/../config/../vendor/rails/activerecord/lib/active_record/associations.rb:355:in `has_many_without_reflection' from (eval):5:in `has_many' from ./script/../config/../config/../app/models/greenback_transaction.rb:2 from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:228:in `load' from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:228:in `load' from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:52:in `require_or_load' from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:52:in `enable_warnings' from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:52:in `require_or_load' from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:28:in `depend_on' from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:199:in `require_dependency' from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:199:in `require_dependency' from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:215:in `const_missing' from (irb):1>> exit $ svn up -r3168 vendor\rails D vendor\rails\activesupport\test\dependencies\raises_exception.rb D vendor\rails\activesupport\test\dependencies\check_warnings.rb U vendor\rails\activesupport\test\dependencies_test.rb U vendor\rails\activesupport\lib\active_support\dependencies.rb U vendor\rails\activesupport\CHANGELOG Updated to revision 3168. $ ruby script\console Loading development environment.>> GreenbackTransaction.new=> #<GreenbackTransaction:0x3733f50 @new_record=true, @attributes={"reason"=>""}>>> exitThe two models in question are: class GreenbackTransaction < ActiveRecord::Base has_many :members, :foreign_key => 'transaction_id', :class_name => 'TransactionMember' end class TransactionMember < ActiveRecord::Base belongs_to :transaction, :class_name => 'GreenbackTransaction', :foreign_key => 'transaction_id' end I found out about this when I couldn't save one of my models. Strange way to find this error, but as I wanted to check if I was doing things correctly in the console, I hit upon this error. Since then, I have created a new Rails application and used the models above and this schema: class InitialSchema < ActiveRecord::Migration def self.up create_table :greenback_transactions do |t| t.column :reason, :string, :limit => 20, :null => false end create_table :transaction_members do |t| t.column :transaction_id, :integer, :null => false t.column :amount, :integer, :null => false end end def self.down end end Both models are valid Ruby: $ ruby -c app\models\greenback_transaction.rb Syntax OK $ ruby -c app\models\transaction_member.rb Syntax OK What needs to be done: 1. Someone else should reproduce this using another environment (WinXP SP2, Ruby 1.8.2, rails-edge@3169) 2. Find out why this changeset is causing this problem. bitsweat is the author of this changeset, and I assume he could help. If you need anything else, I'm all ears. Bye ! -- François Beausoleil http://blog.teksol.info/ _______________________________________________ Rails-core mailing list Rails-core@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-core
Hi, this issue went away for me after svn upping to the latest rev (3188 for me). Regards, Trevor On 24-Nov-05, at 11:07 AM, Francois Beausoleil wrote:> Hi ! > > I have a little problem here. r3169, "Enable warnings on first load > only. File which are loaded but raise an exception are not added to > loaded set" http://dev.rubyonrails.org/changeset/3169 causes stack > level too deep errors while loading my models, using the console. > > $ svn up -r3169 vendor\rails > At revision 3169. > > $ ruby script\console > Loading development environment. >>> GreenbackTransaction.new > SystemStackError: stack level too deep > from ./script/../config/../config/../vendor/rails/ > activerecord/lib/../../activesupport/lib/active_support/ > inflector.rb:121:in > `underscore'' > from ./script/../config/../config/../vendor/rails/ > activerecord/lib/active_record/associations.rb:780:in > `require_association_class'' > from ./script/../config/../config/../vendor/rails/ > activerecord/lib/active_record/associations.rb:355:in > `has_many_without_reflection'' > from (eval):5:in `has_many'' > from ./script/../config/../config/../app/models/ > greenback_transaction.rb:2 > from ./script/../config/../config/../vendor/rails/ > activerecord/lib/../../activesupport/lib/active_support/ > dependencies.rb:228:in > `load'' > from ./script/../config/../config/../vendor/rails/ > activerecord/lib/../../activesupport/lib/active_support/ > dependencies.rb:228:in > `load'' > from ./script/../config/../config/../vendor/rails/ > activerecord/lib/../../activesupport/lib/active_support/ > dependencies.rb:52:in > `require_or_load'' > from ./script/../config/../config/../vendor/rails/ > activerecord/lib/../../activesupport/lib/active_support/ > dependencies.rb:52:in > `enable_warnings'' > from ./script/../config/../config/../vendor/rails/ > activerecord/lib/../../activesupport/lib/active_support/ > dependencies.rb:52:in > `require_or_load'' > from ./script/../config/../config/../vendor/rails/ > activerecord/lib/../../activesupport/lib/active_support/ > dependencies.rb:28:in > `depend_on'' > from ./script/../config/../config/../vendor/rails/ > activerecord/lib/../../activesupport/lib/active_support/ > dependencies.rb:36:in > `associate_with'' > from ./script/../config/../config/../vendor/rails/ > activerecord/lib/../../activesupport/lib/active_support/ > dependencies.rb:200:in > `require_association'' > from ./script/../config/../config/../vendor/rails/ > activerecord/lib/../../activesupport/lib/active_support/ > dependencies.rb:200:in > `require_association'' > from ./script/../config/../config/../vendor/rails/ > activerecord/lib/active_record/associations.rb:780:in > `require_association_class'' > from ./script/../config/../config/../vendor/rails/ > activerecord/lib/active_record/associations.rb:524:in > `belongs_to_without_reflection'' > ... 945 levels... > from ./script/../config/../config/../vendor/rails/ > activerecord/lib/../../activesupport/lib/active_support/ > dependencies.rb:200:in > `require_association'' > from ./script/../config/../config/../vendor/rails/ > activerecord/lib/../../activesupport/lib/active_support/ > dependencies.rb:200:in > `require_association'' > from ./script/../config/../config/../vendor/rails/ > activerecord/lib/active_record/associations.rb:780:in > `require_association_class'' > from ./script/../config/../config/../vendor/rails/ > activerecord/lib/active_record/associations.rb:355:in > `has_many_without_reflection'' > from (eval):5:in `has_many'' > from ./script/../config/../config/../app/models/ > greenback_transaction.rb:2 > from ./script/../config/../config/../vendor/rails/ > activerecord/lib/../../activesupport/lib/active_support/ > dependencies.rb:228:in > `load'' > from ./script/../config/../config/../vendor/rails/ > activerecord/lib/../../activesupport/lib/active_support/ > dependencies.rb:228:in > `load'' > from ./script/../config/../config/../vendor/rails/ > activerecord/lib/../../activesupport/lib/active_support/ > dependencies.rb:52:in > `require_or_load'' > from ./script/../config/../config/../vendor/rails/ > activerecord/lib/../../activesupport/lib/active_support/ > dependencies.rb:52:in > `enable_warnings'' > from ./script/../config/../config/../vendor/rails/ > activerecord/lib/../../activesupport/lib/active_support/ > dependencies.rb:52:in > `require_or_load'' > from ./script/../config/../config/../vendor/rails/ > activerecord/lib/../../activesupport/lib/active_support/ > dependencies.rb:28:in > `depend_on'' > from ./script/../config/../config/../vendor/rails/ > activerecord/lib/../../activesupport/lib/active_support/ > dependencies.rb:199:in > `require_dependency'' > from ./script/../config/../config/../vendor/rails/ > activerecord/lib/../../activesupport/lib/active_support/ > dependencies.rb:199:in > `require_dependency'' > from ./script/../config/../config/../vendor/rails/ > activerecord/lib/../../activesupport/lib/active_support/ > dependencies.rb:215:in > `const_missing'' > from (irb):1>> exit > > $ svn up -r3168 vendor\rails > D vendor\rails\activesupport\test\dependencies\raises_exception.rb > D vendor\rails\activesupport\test\dependencies\check_warnings.rb > U vendor\rails\activesupport\test\dependencies_test.rb > U vendor\rails\activesupport\lib\active_support\dependencies.rb > U vendor\rails\activesupport\CHANGELOG > Updated to revision 3168. > > $ ruby script\console > Loading development environment. >>> GreenbackTransaction.new > => #<GreenbackTransaction:0x3733f50 @new_record=true, > @attributes={"reason"=>""}> >>> exit > > The two models in question are: > class GreenbackTransaction < ActiveRecord::Base > has_many :members, :foreign_key => ''transaction_id'', > :class_name => ''TransactionMember'' > end > > class TransactionMember < ActiveRecord::Base > belongs_to :transaction, :class_name => ''GreenbackTransaction'', > :foreign_key => ''transaction_id'' > end > > I found out about this when I couldn''t save one of my models. Strange > way to find this error, but as I wanted to check if I was doing things > correctly in the console, I hit upon this error. > > Since then, I have created a new Rails application and used the models > above and this schema: > class InitialSchema < ActiveRecord::Migration > def self.up > create_table :greenback_transactions do |t| > t.column :reason, :string, :limit => 20, :null => false > end > > create_table :transaction_members do |t| > t.column :transaction_id, :integer, :null => false > t.column :amount, :integer, :null => false > end > end > > def self.down > end > end > > Both models are valid Ruby: > $ ruby -c app\models\greenback_transaction.rb > Syntax OK > > $ ruby -c app\models\transaction_member.rb > Syntax OK > > What needs to be done: > 1. Someone else should reproduce this using another environment (WinXP > SP2, Ruby 1.8.2, rails-edge@3169) > > 2. Find out why this changeset is causing this problem. bitsweat is > the author of this changeset, and I assume he could help. > > If you need anything else, I''m all ears. > > Bye ! > -- > François Beausoleil > http://blog.teksol.info/ > _______________________________________________ > Rails-core mailing list > Rails-core@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-core
Hi ! 2005/11/24, Trevor Squires <trevor@protocool.com>:> this issue went away for me after svn upping to the latest rev (3188 > for me).Yes, I concur. Sorry for the noise. I also just found my real problem: class TransactionMember < ActiveRecord::Base belongs_to :transaction, :class_name => 'GreenbackTransaction', :foreign_key => 'transaction_id' end Isn't there a #transaction method ? No, really... Renamed :transaction to :parent_txn and my other problem went away. Have a nice day ! -- François Beausoleil http://blog.teksol.info/ _______________________________________________ Rails-core mailing list Rails-core@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-core
> Yes, I concur. Sorry for the noise. I also just found my real problem: > > class TransactionMember < ActiveRecord::Base > belongs_to :transaction, :class_name => ''GreenbackTransaction'', > :foreign_key => ''transaction_id'' > end > > Isn''t there a #transaction method ? No, really... Renamed > :transaction to :parent_txn and my other problem went away. > > Have a nice day !SystemStackError isn''t the user experience we''re after though... Was there anything in your logs warning you that you''d overridden transaction? -- Cheers Koz
2005/11/24, Michael Koziarski <michael@koziarski.com>:> SystemStackError isn't the user experience we're after though... > > Was there anything in your logs warning you that you'd overridden transaction?Nope, and I have had the same kind of error with other base class methods: quote, transaction. What we need is a check in has_many, has_one, belongs_to and has_and_belongs_to_many that checks whether the method already exists in the current context, and bail out if it does. Something like this: def has_many(...) ... check_association_method_not_already_exist(association_name) ... end def check_association_method_not_already_exist(association_name) raise InvalidAssociationName, "Association name #{association_name} already exists - you can't use it" if self.class.methods.include?(association_name) end Untested, but should be about right, no ? Ok ok, I do volunteer to write the patch :) Unless someone's already on it ? Bye ! -- François Beausoleil http://blog.teksol.info/ _______________________________________________ Rails-core mailing list Rails-core@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-core
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 The mutual dependencies error introduced in [3169] is fixed in [3181]. jeremy -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (Darwin) iD8DBQFDhhwpAQHALep9HFYRAjLbAKDGdIo6Mt/lbhYPBQbQwL9vQWcT8wCeP35o Yxalq/jkefkiUm1DKqaZKYI=Y2fT -----END PGP SIGNATURE-----
> Untested, but should be about right, no ? Ok ok, I do volunteer to > write the patch :) Unless someone''s already on it ?"Please do look into that" There are two cases though: 1) people declaring associations which conflict (quote is the most common problem I''ve seen) 2) people with columns which conflict (system, quote and sleep have caused issues in the past) The ideal case is that we fail fast, really fast, and don''t let the app continue running. But a proper warning is a good start. -- Cheers Koz
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Nov 24, 2005, at 12:00 PM, Francois Beausoleil wrote:> 2005/11/24, Michael Koziarski <michael@koziarski.com>: >> SystemStackError isn''t the user experience we''re after though... >> >> Was there anything in your logs warning you that you''d overridden >> transaction? > > Nope, and I have had the same kind of error with other base class > methods: quote, transaction.Bummer. The whole point of this warnings stuff is so that you get a message in your logs telling you that you''re overriding an existing method. If you''re on FastCGI, the message will appear in your web server''s error log, not in development.log. This is known; we need to redirect STDERR to the current environment''s logfile. Or even STDERR.reopen(File.open(configuration.log_path)) configuration.logger = Logger.new(STDERR) jeremy -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (Darwin) iD8DBQFDhh7uAQHALep9HFYRArSDAJ9gU8K+qHbyThWm3uGG0iZsd8X2mACguXq+ aTUQ8L+2iAckSruEnmenmvI=PGSd -----END PGP SIGNATURE-----
2005/11/24, Jeremy Kemper <jeremy@bitsweat.net>:> Bummer. The whole point of this warnings stuff is so that you get a > message in your logs telling you that you're overriding an existing > method. If you're on FastCGI, the message will appear in your > web server's error log, not in development.log. This is known; we > need to redirect STDERR to the current environment's logfile. > > Or even > STDERR.reopen(File.open(configuration.log_path)) > configuration.logger = Logger.new(STDERR)I do not address this case in my patch, but you may check out what it does: http://dev.rubyonrails.org/ticket/3005 I took the liberty to up the priority and the severity. This is a serious issue that I faced myself multiple times. Enjoy ! -- François Beausoleil http://blog.teksol.info/ _______________________________________________ Rails-core mailing list Rails-core@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-core
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Nov 24, 2005, at 12:35 PM, Francois Beausoleil wrote:> 2005/11/24, Jeremy Kemper <jeremy@bitsweat.net>: >> Bummer. The whole point of this warnings stuff is so that you get a >> message in your logs telling you that you''re overriding an existing >> method. If you''re on FastCGI, the message will appear in your >> web server''s error log, not in development.log. This is known; we >> need to redirect STDERR to the current environment''s logfile. >> >> Or even >> STDERR.reopen(File.open(configuration.log_path)) >> configuration.logger = Logger.new(STDERR) > > I do not address this case in my patch, but you may check out what > it does: > http://dev.rubyonrails.org/ticket/3005 > > I took the liberty to up the priority and the severity. This is a > serious issue that I faced myself multiple times.Thank you; the patch looks good. I''ll be away for a bit (holiday) but another committer will likely merge it to trunk and the stable branch. Extra thanks for unit testing your patch. jeremy -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (Darwin) iD8DBQFDhii4AQHALep9HFYRApMCAJ4sFbxb1QQgbN45bsUD6J15cE5UlgCghwfe btPJAe7aC+XpVQsUjR4+pSg=3c/b -----END PGP SIGNATURE-----