Is it possible to do a validates_uniqueness_of :name, :zip but only in that context? I''d like to be able to have that zip used again, but not in conjunction with a name already with that zip. Does that make sense? -- Posted via http://www.ruby-forum.com/.
Guest wrote:> Is it possible to do a validates_uniqueness_of :name, :zip but only in > that context? I''d like to be able to have that zip used again, but not > in conjunction with a name already with that zip. > > Does that make sense?I''m new to Rails, but I think validate_uniqueness_of :name, :scope=>:zip should do what you want. -- Posted via http://www.ruby-forum.com/.
Perfect. Thanks yo. Eric Nielsen wrote:> Guest wrote: >> Is it possible to do a validates_uniqueness_of :name, :zip but only in >> that context? I''d like to be able to have that zip used again, but not >> in conjunction with a name already with that zip. >> >> Does that make sense? > > I''m new to Rails, but I think validate_uniqueness_of :name, :scope=>:zip > should do what you want.-- Posted via http://www.ruby-forum.com/.
Guest wrote:> Is it possible to do a validates_uniqueness_of :name, :zip but only in > that context? I''d like to be able to have that zip used again, but not > in conjunction with a name already with that zip. > > Does that make sense? > > >Do you mean that the zip needs to be unique for each name (i.e. each name can have only one of each zip), or the other way round. If it''s the former, try: validates_uniqueness of :zip, :scope => :name