Ruby on rails 谷歌地图不适用于RubyonRails 4.1.1
我按照教程在网页上显示地图,但它不起作用。 出现以下错误: 未定义的局部变量或方法<代码>充当# app/models/character.rb:2:in' app/models/character.rb:1:inRuby on rails 谷歌地图不适用于RubyonRails 4.1.1,ruby-on-rails,json,google-maps,gmaps4rails,Ruby On Rails,Json,Google Maps,Gmaps4rails,我按照教程在网页上显示地图,但它不起作用。 出现以下错误: 未定义的局部变量或方法充当# app/models/character.rb:2:in' app/models/character.rb:1:in' app/controllers/characters\u controller.rb:7:inindex' 我已经尝试了几乎所有可能的方法:重新启动服务器、捆绑包安装和捆绑包更新: 这是相关文件 字符\u controller.rb class CharactersController &
'
app/controllers/characters\u controller.rb:7:in
index'
我已经尝试了几乎所有可能的方法:重新启动服务器、捆绑包安装和捆绑包更新:
这是相关文件
字符\u controller.rb
class CharactersController < ApplicationController
before_action :set_character, only: [:show, :edit, :update, :destroy]
# GET /characters
# GET /characters.json
def index
@characters = Character.all
json = Character.all.to_gmaps4rails
end
# GET /characters/1
# GET /characters/1.json
def show
end
# GET /characters/new
def new
@character = Character.new
end
类字符控制器
character.rb
class Character < ActiveRecord::Base
acts_as_gmappable
def gmaps4rails_address
address
end
end
类字符
index.html.erb
<h1>Listing characters</h1>
<table>
<thead>
<tr>
<th>Name</th>
<th>Address</th>
<th>Longitude</th>
<th>Latitude</th>
<th>Gmaps</th>
<th colspan="3"></th>
</tr>
</thead>
<tbody>
<% @characters.each do |character| %>
<tr>
<td><%= character.name %></td>
<td><%= character.address %></td>
<td><%= character.longitude %></td>
<td><%= character.latitude %></td>
<td><%= character.gmaps %></td>
<td><%= link_to 'Show', character %></td>
<td><%= link_to 'Edit', edit_character_path(character) %></td>
<td><%= link_to 'Destroy', character, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
</table>
<br>
<%= link_to 'New Character', new_character_path %>
<%= gmaps4rails(#json) %>
列出字符
名称
住址
经度
纬度
谷歌地图
如果你需要我提供更多信息,请告诉我。我已经在这上面花了很多时间
提前感谢。本教程已弃用,仅适用于1.x版本
wiki中的文档说明如下所示:您遵循的是什么教程。。。。这个Apneadiving@sevenseacat ... 领头羊