问题
I have this code that was working on my rails app that is using google Translate API, but on my last commit to heroku I got the error
ArgumentError: unknown keyword: project
It seems that my google analytics is not working neither. Don't know what is causing the error. Maybe you have a hint ?
translate = Google::Cloud::Translate.new project: "my_project"
description_translation = translate.translate params[:description], to: 'en'
update_attribute(:description, description_translation)
回答1:
project was an alias for project_id. It was deprecated since version 1.1.0 of the library.
Your code presumably stopped working because you updated the library to version 2.0.0 (or above) - since here, in this PR, support for the project parameter was fully dropped.
To fix this error, simply rename project to project_id.
Also take note of any other potentially-breaking changes here, in the CHANGELOG. As shown in that link, you may wish to temporarily use version: :v2 to help ease the migration if there are further complications.
来源:https://stackoverflow.com/questions/58916608/rails-google-translate-api-argumenterror-unknown-keyword-project