Question

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.

Was it helpful?

Solution

If Librarian has library_id:

validates_uniqueness_of :name, :scope => :library_id
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top