Assume you have a tree, where you want to have set attributes only, if a node is a root. Otherwise the model should not accept entries for a specific attribute.
I.e. if you have a tree of categories and want to have a locale attribute only on roots you could do s'thing like this: class Category < ActiveRecord::Base validates :locale, :presence => true, :if => :root? validates :locale, :absence => true, :unless => :root? end Actually I'm doing this a lot. I'll use s'thing else, if someone has a better pattern. Cheers, Roberto -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-core/-/_Qgt0vhDA4wJ. 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-core?hl=en.
