前提・実現したいこと
登録したデータの詳細画面に遷移したいのですがエラーがでてしまいます。
発生している問題・エラーメッセージ
ActionController::UrlGenerationError in Maps#index No route matches {:action=>"show", :controller=>"maps", :id=>nil}, missing required keys: [:id] //住所を変数に代入 var contentString = '<%= link_to m.name,map_path(@map) %>';
該当のソースコード
indexhtml
1<% @maps.each do |m| %> 2(function(){ 3 4 //住所を変数に代入 5 var contentString = '<%= link_to m.name,map_path(@map) %>'; 6 7 //吹き出しの追加 8 var infowindow = new google.maps.InfoWindow({ 9 content: contentString //吹き出しに表示する内容 10 });
controller
1class MapsController < ApplicationController 2 3 def index 4 @maps = Map.all 5 end 6 7 def show 8 @map = Map.find(params[:id]) 9 @map_comment = MapComment.new 10 @counts = Count.where(user_id: current_user.id) 11 end 12 13 def mypage 14 @bookmarks = Bookmark.where(user_id: current_user.id) 15 end 16 17end 18
root
1 map GET /maps/:id(.:format) maps#show
試したこと
自分の勉強不足で止まっていしまっています。どなたかご教授お願いいたします。
補足情報(FW/ツールのバージョンなど)
ここにより詳細な情報を記載してください。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2021/12/18 01:24