`student_book_id = current_profile.books.find_by(book_id: book.id)`
books might be different in your case, but you should be able to find it this way and take some more complexity out of your controller.