Nicholas, Thank you very much for working on this.
I ran the test suit but got errors. I modified the test suite: https://gist.github.com/4c009e230862d3a2e58a , using the users.yml: https://gist.github.com/1c282b5b006326cca497 Note that I changed the attribute name "aspect" to "score_aspect" Below are the errors. Thank you for your help. ruby test/unit/stat_test2.rb Loaded suite test/unit/stat_test2 Started E...EEEE Finished in 1.227252 seconds. 1) Error: test_should_add_error_on_score_aspect_when_validating_with_the_same_score_aspect (StatTest): ActiveRecord::RecordInvalid: Validation failed: Score aspect has already been taken test/unit/stat_test2.rb:33:in `test_should_add_error_on_score_aspect_when_validating_with_the_same_score_aspect' 2) Error: test_should_not_add_error_on_score_aspect_when_validating_an_updated_stat (StatTest): ActiveRecord::RecordInvalid: Validation failed: Score aspect has already been taken test/unit/stat_test2.rb:41:in `test_should_not_add_error_on_score_aspect_when_validating_an_updated_stat' 3) Error: test_should_not_add_error_on_score_aspect_when_validating_with_a_different_score_aspect (StatTest): ActiveRecord::RecordInvalid: Validation failed: Score aspect has already been taken test/unit/stat_test2.rb:25:in `test_should_not_add_error_on_score_aspect_when_validating_with_a_different_score_aspect' 4) Error: test_should_score_aspect_be_read_only(StatTest): ActiveRecord::RecordInvalid: Validation failed: Score aspect has already been taken test/unit/stat_test2.rb:49:in `test_should_score_aspect_be_read_only' 5) Error: test_should_user_be_read_only(StatTest): ActiveRecord::RecordInvalid: Validation failed: Score aspect has already been taken test/unit/stat_test2.rb:57:in `test_should_user_be_read_only' 8 tests, 3 assertions, 0 failures, 5 errors On Jul 6, 3:53 pm, Nicholas Henry <[email protected]> wrote: > I haven't been able to reproduce the issue that you have been having > (on 2.3.2). I created a test suite for your model. Can you run that to > see if you get the same problem. > > http://gist.github.com/141740 > > Requires mocha, update references to fixtures and fields as required. > It's based on the migration and model you provided. > > HTH, > Nicholas > > On Jul 5, 11:59 pm, Learn by Doing <[email protected]> > wrote: > > > Colin: > > > Below are the relevant code. Thanks for your help. > > > class CreateStats < ActiveRecord::Migration > > > def self.up > > create_table :stats do |t| > > > t.integer :user_id, :null => false > > t.string :aspect, :null => false, :default => "default > > aspect" > > > t.timestamps > > end > > end > > > def self.down > > drop_table :stats > > end > > end > > > class Stat < ActiveRecord::Base > > > belongs_to :user > > validates_presence_of :user_id > > validates_associated :user > > > validates_uniqueness_of :aspect, :scope => :user_id > > > attr_readonly :user_id, :aspect > > > end > > > -- > > Posted viahttp://www.ruby-forum.com/. > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

