I'm trying to check if new submissions match certain aspects of existing submissions and, if so, prevent it from being created.
if ( !Book.exists?(author: @book.author) and !Book.exists?(publisher: @book.publisher) ) or ( !Book.exists?(name: @book.name) and !Book.exists?(genre: @book.genre) ) ...create The problem is that if the genre and the publisher match existing records, the book is not created. That's clearly not what I intend with those operators. I tried && and || and also mixed them with and and or, knowing && and || take precedence. I also tried placing the second logic into elsif. No use. I'd appreciate any help.
https://stackoverflow.com/questions/67293001/filtering-at-create-rails April 28, 2021 at 10:31AM
没有评论:
发表评论