Rails - Google Translate API : ArgumentError: unknown keyword: project

╄→尐↘猪︶ㄣ 提交于 2020-01-25 06:41:13

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!