rails 5.1.6
、ruby 2.5.0
で開発しています。
Google Mapが表示されるプログラムを書いているのですが、controller
内で動く以下コードが、erb
内に移すと以下のようなエラーが出てしまいます。
どうしてもerb
内に書く必要があるのですが、ご指南いただきたくお願いします。
ruby
1### contollerの記載 -> 問題なく動きます 2def top 3 @notes = Note.order(updated_at: :desc).limit(10) 4 @countries_count = Note.group(:address_country_part).order(:address_country_part).count 5 @notes_all = Note.all 6 @hash = Gmaps4rails.build_markers(@notes_all) do |note, marker| 7 marker.lat note.latitude 8 marker.lng note.longitude 9 marker.infowindow render_to_string(partial: "shared/infowindow", locals: { note: note }) 10 end 11 end 12 13### erb内の記載 14 <% 15 @note = note 16 @hash_each = Gmaps4rails.build_markers(note) do |note, marker| 17 marker.lat note.latitude 18 marker.lng note.longitude 19 marker.infowindow render_to_string(partial: "shared/infowindow", locals: { note: note }) 20 end 21 22 %> 23 24 <script type="text/javascript"> 25 handler = Gmaps.build('Google'); 26 handler.buildMap({ provider: {}, internal: {id: 'map-<%= note.id %>'}}, function(){ 27 markers = handler.addMarkers(<%=raw @hash_each.to_json %>); 28 handler.bounds.extendWith(markers); 29 handler.fitMapToBounds(); 30 }); 31 </script> 32
結果undefined method render_to_string
とのエラーが出ます
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/11/07 07:05