:validate => true on a belongs_to tells Rails to validate the owner
record when the owner record is being saved in order to get a foreign
key value for the association. This doesn't seem to make sense,
because you cannot save an association without saving first the owning
record, so let's say:

class Address < ActiveRecord::Base
  belongs_to :user, :validate => true
end


class User < ActiveRecord::BAse
  has_many :addresses
end

u = User.new
a = Address.new
u.addresses << a

u.save #I guess this is the only time when the belongs_to :validate =>
true will be fired, that is, when we are saving the owner record. But
this doesn't make sense because the owner record's own validation
would be triggered anyway when we do this. So I still don't understand
the purpose of :validate => true on a belongs_to relation.

thanks for response

-- 
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 https://groups.google.com/groups/opt_out.


Reply via email to