Я пытаюсь собрать JSON с данными Geojson.
В моем контроллере:
def index
....
respond_to do |format|
format.html
format.json { render json: { type: 'FeatureCollection', features: pois_geojson + tracks_geojson} }
end
и для шоу
def show
...
respond_to do |format|
format.html
format.json { render json: { type: 'FeatureCollection', features: poi_geojson + track_geojson} }
end
Для индекса все работает нормально имой JSON это хорошо.Я называю этот метод для сборки json.
Методы для показа
def poi_geojson
{
type: 'Feature',
RGeo::GeoJSON.encode(@poi.lonlat),
properties: {
name: @poi.name,
:'marker-color' => '#00607d',
:'marker-symbol' => 'circle',
:'marker-size' => 'medium'
}
}
end
def track_geojson
{
type: 'Feature',
geometry: RGeo::GeoJSON.encode(@track.path),
properties: {
:'color' => '#ff7800',
:'weight' => '5',
:'opacity' => '0.65'
}
}
end
Методы для индекса
def pois_geojson
@pois.map do |poi|
{
type: 'Feature',
RGeo::GeoJSON.encode(poi.lonlat)
properties: {
name: poi.name,
:'marker-color' => '#00607d',
:'marker-symbol' => 'circle',
:'marker-size' => 'medium'
}
}
end
end
def tracks_geojson
@tracks.map do |track|
{
type: 'Feature',
geometry: RGeo::GeoJSON.encode(track.path),
properties: {
:'color' => '#ff7800',
:'weight' => '5',
:'opacity' => '0.65'
}
}
end
end
Как видите, методы похожи, но яЯ не понимаю, почему для индекса он работает нормально, а не для шоу.
У меня есть эта ошибка:
`неопределенный метод '+' для #` для этой строки:`format.json {render json: {type: 'FeatureCollection', функции: poi_geojson + track_geojson}}`