Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/397.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Rails 4-使用gmaps4rails gem的谷歌地图_Javascript_Ruby On Rails_Google Maps_Gmaps4rails - Fatal编程技术网

Javascript Rails 4-使用gmaps4rails gem的谷歌地图

Javascript Rails 4-使用gmaps4rails gem的谷歌地图,javascript,ruby-on-rails,google-maps,gmaps4rails,Javascript,Ruby On Rails,Google Maps,Gmaps4rails,我正试图弄清楚如何在我的Rails 4应用程序中使用gmaps4rails gem 我有一个部分视图,其中插入了文档中显示的3个脚本标记,用我自己的API密钥(存储在我的环境机密文件中)替换API密钥 有人能看到我将API密钥插入此脚本的方式是否出错吗?您正在将ruby片段插入.html.erb文件中,因此需要插入ruby字符串 <script src="//maps.google.com/maps/api/js?v=3.23&key=<%= ENV['GOOGLE_MAPS

我正试图弄清楚如何在我的Rails 4应用程序中使用gmaps4rails gem

我有一个部分视图,其中插入了文档中显示的3个脚本标记,用我自己的API密钥(存储在我的环境机密文件中)替换API密钥


有人能看到我将API密钥插入此脚本的方式是否出错吗?

您正在将ruby片段插入
.html.erb
文件中,因此需要
插入ruby字符串

<script src="//maps.google.com/maps/api/js?v=3.23&key=<%= ENV['GOOGLE_MAPS_API_KEY'] %>"></script>


检查ur html页面的inspect元素,查看url是否正确插入。

谢谢@Vic-我尝试了这一点,我仍然收到上面列出的无效api密钥错误,但至少不是因为我输入了错误的api密钥听到很好!这应该意味着api密钥在某种程度上是错误的……可能是拼写错误、密钥错误、项目密钥错误、使用了ios密钥而不是服务器密钥?我只是在猜测我上次使用谷歌API时犯的一些错误:)调试愉快哈哈!
util.js:220 Google Maps API warning: InvalidKey https://developers.google.com/maps/documentation/javascript/error-messages#invalid-key
<script src="//maps.google.com/maps/api/js?v=3.23&key=<%= ENV['GOOGLE_MAPS_API_KEY'] %>"></script>