Category.has_many :products

Let's say a product must belong to a category. I know it is recommended
to do the following:

class Product
validates_presence_of :category_id
end

But, as we all know, this is a pain for new records, meaning what if the
associated category is a new record?

I've been meaning to ask this, but what's wrong with doing the
following:

class Product
validates_presence_of :category
end

I never understood why that was so wrong. So I wanted to ask and see if
I am missing something. What do you think? Thanks for your help!
-- 
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