John Mackin
2009-Apr-26 09:22 UTC
validators.rb breaks after update from Rails 2.2.2 to 2.3.2
I just updated my rails application from 2.2.2 to 2.3.2 and the following message is displayed while trying to start with ./script/ server: [code] => Booting Mongrel => Rails 2.3.2 application starting on http://0.0.0.0:3000 /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/ active_support/core_ext/module/aliasing.rb:33:in `alias_method'': undefined method `valid?'' for class `ActiveRecord::Base'' (NameError) from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/ active_support/core_ext/module/aliasing.rb:33:in `alias_method_chain'' from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/ active_record/callbacks.rb:224:in `send'' from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/ active_record/callbacks.rb:224:in `included'' from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/ active_record/callbacks.rb:223:in `each'' from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/ active_record/callbacks.rb:223:in `included'' from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/ active_record/base.rb:3143:in `include'' from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/ active_record/base.rb:3143 from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/ active_record/base.rb:3137:in `class_eval'' ... 11 levels... from /opt/local/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/commands/ server.rb:84 from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb: 31:in `gem_original_require'' from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb: 31:in `require'' from ./script/server:3 [/code] I figured out that if I comment out "require ''validators.rb''" inside my environment.rb than it''ll work fine. Validators.rb (http:// pastie.org/457289) handles some special validations and sits in my lib directory. I am wondering what has changed from 2.2.2 to 2.3.2 that all the sudden this rather simple extension wouldn''t work anymore. Does any have an idea? JM
Matt Jones
2009-Apr-27 23:17 UTC
Re: validators.rb breaks after update from Rails 2.2.2 to 2.3.2
My guess would be some change to the load order - you''d be better off loading your custom validations in an initializer, so that ActiveRecord is loaded. --Matt Jones On Apr 26, 5:22 am, John Mackin <bushg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I just updated my rails application from 2.2.2 to 2.3.2 and the > following message is displayed while trying to start with ./script/ > server: > > [code] > => Booting Mongrel > => Rails 2.3.2 application starting onhttp://0.0.0.0:3000/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.... > active_support/core_ext/module/aliasing.rb:33:in `alias_method'': > undefined method `valid?'' for class `ActiveRecord::Base'' (NameError) > from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/ > active_support/core_ext/module/aliasing.rb:33:in `alias_method_chain'' > from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/ > active_record/callbacks.rb:224:in `send'' > from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/ > active_record/callbacks.rb:224:in `included'' > from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/ > active_record/callbacks.rb:223:in `each'' > from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/ > active_record/callbacks.rb:223:in `included'' > from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/ > active_record/base.rb:3143:in `include'' > from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/ > active_record/base.rb:3143 > from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/ > active_record/base.rb:3137:in `class_eval'' > ... 11 levels... > from /opt/local/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/commands/ > server.rb:84 > from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb: > 31:in `gem_original_require'' > from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb: > 31:in `require'' > from ./script/server:3 > [/code] > > I figured out that if I comment out "require ''validators.rb''" inside > my environment.rb than it''ll work fine. Validators.rb (http:// > pastie.org/457289) handles some special validations and sits in my lib > directory. > > I am wondering what has changed from 2.2.2 to 2.3.2 that all the > sudden this rather simple extension wouldn''t work anymore. > > Does any have an idea? > > JM