Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Scoped uniqueness validation of associated objects

#6673

class Poll < ActiveRecord::Base
has_many :answers

validates_associated :answers

accepts_nested_attributes_for :answers, :allow_destroy => true end

class Answer < ActiveRecord::Base
belongs_to :poll

validates_uniqueness_of :body, :scope => :poll_id end

When new poll is created,
attributes for associated answers are passed,
but uniqueness of answers body in scope of poll is not validated.

Any ideas how to fix that.

Reported by Andriy Tyurnikov · April 5th, 2011 @ 11:41 AM

State: new
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. Kane
    Kane

    can you supply a failing test case?

    April 6th, 2011 @ 12:38 AM