Skip to content

Instantly share code, notes, and snippets.

@sbatson5
Created January 22, 2025 17:57
Show Gist options
  • Save sbatson5/8f1e18e816cad1f7869b088e4b0a2681 to your computer and use it in GitHub Desktop.
Save sbatson5/8f1e18e816cad1f7869b088e4b0a2681 to your computer and use it in GitHub Desktop.
def run
genres_array = fetch_genres_from_openai
return if genres_array.blank?
book.genres.clear
genres_array.each do |genre_name|
genre = Genre.find_by(name: genre_name)
puts "adding genre #{genre_name} to document profile #{book.id}"
book.genres << genre if genre.present?
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment