문제

I have a form for Library, which has several nested objects for Librarian. My question is:

How can I validate uniqueness of Librarian's name? (there may be multiple librarians for one library, but there should not be the same librarian appears twice). I found a hint but couldn't make it work:

    validates_uniqueness_of :task_name, :scope => :project_id

Please give me an example, because I found pieces to the puzzle but have not been able to put them together.

도움이 되었습니까?

해결책

If Librarian has library_id:

validates_uniqueness_of :name, :scope => :library_id
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top