Quoting Learn by Doing <rails-mailing-l...@andreas-s.net>: > > I have a problem running find using composite primary keys. I have the > following models: > > > Code : - fold - unfold > > 1. class Stat < ActiveRecord::Base > 2. set_primary_keys :user_id, :score_aspect > 3. belongs_to :user > > > Code : - fold - unfold > > 1. class User < ActiveRecord::Base > 2. has_many :stats > > Stat.find runs fine when it can find a stat. But it returns error > instead of "nil", when it cannot find a stat. > >
This is normal behavior, when calling find with a non-existant primary key, it throws an exception, ActiveRecord::RecordNotFound. Try it on one of your other classes, e.g., User.find(99999999). HTH, Jeffrey --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---