Here is the method that is blowing up: ===================== greeting.rb ============================== class Greeting < ActiveRecord::Base after_initialize :check_greet validates_uniqueness_of :count
def check_greet self.language = language.capitalize end end ============================================================ And here is the backtrace I get when I run the unit test posted earlier: ============================================================ Loaded suite /home/ded/.rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.1/lib/rake/rake_test_loader Started E Finished in 0.280612 seconds. 1) Error: test_uniqueness_of_count(GreetingTest): ActiveModel::MissingAttributeError: missing attribute: language /home/ded/Rails/demo/app/models/greeting.rb:6:in `check_greet' /home/ded/.rvm/gems/ruby-1.9.2-p180@rails303/gems/activesupport-3.0.3/lib/active_support/callbacks.rb:415:in `_run_initialize_callbacks' /home/ded/.rvm/gems/ruby-1.9.2-p180@rails303/gems/activerecord-3.0.3/lib/active_record/base.rb:1453:in `init_with' /home/ded/.rvm/gems/ruby-1.9.2-p180@rails303/gems/activerecord-3.0.3/lib/active_record/base.rb:909:in `instantiate' /home/ded/.rvm/gems/ruby-1.9.2-p180@rails303/gems/activerecord-3.0.3/lib/active_record/base.rb:467:in `block in find_by_sql' /home/ded/.rvm/gems/ruby-1.9.2-p180@rails303/gems/activerecord-3.0.3/lib/active_record/base.rb:467:in `collect!' /home/ded/.rvm/gems/ruby-1.9.2-p180@rails303/gems/activerecord-3.0.3/lib/active_record/base.rb:467:in `find_by_sql' /home/ded/.rvm/gems/ruby-1.9.2-p180@rails303/gems/activerecord-3.0.3/lib/active_record/relation.rb:64:in `to_a' /home/ded/.rvm/gems/ruby-1.9.2-p180@rails303/gems/activerecord-3.0.3/lib/active_record/relation/finder_methods.rb:333:in `find_first' /home/ded/.rvm/gems/ruby-1.9.2-p180@rails303/gems/activerecord-3.0.3/lib/active_record/relation/finder_methods.rb:122:in `first' /home/ded/.rvm/gems/ruby-1.9.2-p180@rails303/gems/activerecord-3.0.3/lib/active_record/relation/finder_methods.rb:180:in `exists?' /home/ded/.rvm/gems/ruby-1.9.2-p180@rails303/gems/activerecord-3.0.3/lib/active_record/validations/uniqueness.rb:39:in `validate_each' /home/ded/.rvm/gems/ruby-1.9.2-p180@rails303/gems/activemodel-3.0.3/lib/active_model/validator.rb:154:in `block in validate' /home/ded/.rvm/gems/ruby-1.9.2-p180@rails303/gems/activemodel-3.0.3/lib/active_model/validator.rb:151:in `each' /home/ded/.rvm/gems/ruby-1.9.2-p180@rails303/gems/activemodel-3.0.3/lib/active_model/validator.rb:151:in `validate' /home/ded/.rvm/gems/ruby-1.9.2-p180@rails303/gems/activesupport-3.0.3/lib/active_support/callbacks.rb:314:in `_callback_before_7' /home/ded/.rvm/gems/ruby-1.9.2-p180@rails303/gems/activesupport-3.0.3/lib/active_support/callbacks.rb:414:in `_run_validate_callbacks' /home/ded/.rvm/gems/ruby-1.9.2-p180@rails303/gems/activemodel-3.0.3/lib/active_model/validations.rb:212:in `run_validations!' /home/ded/.rvm/gems/ruby-1.9.2-p180@rails303/gems/activemodel-3.0.3/lib/active_model/validations/callbacks.rb:67:in `block in run_validations!' /home/ded/.rvm/gems/ruby-1.9.2-p180@rails303/gems/activesupport-3.0.3/lib/active_support/callbacks.rb:413:in `_run_validation_callbacks' /home/ded/.rvm/gems/ruby-1.9.2-p180@rails303/gems/activemodel-3.0.3/lib/active_model/validations/callbacks.rb:67:in `run_validations!' /home/ded/.rvm/gems/ruby-1.9.2-p180@rails303/gems/activemodel-3.0.3/lib/active_model/validations.rb:179:in `valid?' /home/ded/.rvm/gems/ruby-1.9.2-p180@rails303/gems/activerecord-3.0.3/lib/active_record/validations.rb:55:in `valid?' /home/ded/Rails/demo/test/unit/greeting_test.rb:7:in `block in <class:GreetingTest>' 1 tests, 0 assertions, 0 failures, 1 errors, 0 skips Test run options: --seed 44283 rake aborted! Command failed with status (1): [/home/ded/.rvm/rubies/ruby-1.9.2-p180/bin/...] -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/pnZbASl-POAJ. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.