I’m new to ROR. Can anyone tell me what does the validate option do in belongs_to with an example?
class Product < ActiveRecord::Base
belongs_to :category, validate => true
end
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In rare cases Rails allows to create an parent object for the dependent, for example:
product.create_category!(docs). Aboutvalidateoption docs:That means that when you save the product, by default the category is not validated. In your case the category will be validated.