Jeffrey:

Thank you.  I tried that but it still didn't work.  So I have this

class Stat < ActiveRecord::Base

  belongs_to :user
  validates_presence_of   :user_id
  validates_associated    :user


The user table is empty.  I then create a stat with user_id = 99, which 
does not exist in the user table.  No error is produced:

Loading development environment (Rails 2.3.2)
>> stat = Stat.new(:user_id => 99)
=> #<Stat id: nil, user_id: 99, ...>
>> stat.save!
=> true
>> 

A new record with user_id = 99 was created in the database although the 
associated user does not exist.  Perhaps this validation only validates 
the associated user when that user exists.  See API: 
http://apidock.com/rails/ActiveModel/Validations/ClassMethods/validates_associated

Did I read it right?

Thanks.
-- 
Posted via http://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
-~----------~----~----~----~------~----~------~--~---

Reply via email to