あなたが提供できる助けを前もって感謝します!
私の Ruby on Rails Web サイト (1.8.7、2.3.15) で、MySQL テーブルからデータを取得しようとしていますが、「未定義のメソッド」エラーが発生します。このコードの目的は、特定の緯度と経度の範囲内にあるすべての場所のテキスト リストを表示することです。
Production.log:
ActionView::TemplateError (undefined method `each' for nil:NilClass) on line #31 of app/views/its/map.html.erb:
28: <!-- TestingLocations -->
29:
30: <ul id="locations">
31: <% for masterlocation in @nearbylocations %>
32: <li><%= masterlocation.nickname %></a></li>
33: <% end %>
34: </ul>
マップ コントローラー:
def map
@its = Its.find(params[:id])
if @its.user_id == current_user.id
@locations = Location.find(:all, :conditions => ["its_id = ?", params[:id]], :order => "order_num asc")
@mapscount = Saved.count(:all, :conditions => ['its_id = ?', params[:id]])
#@date_filter = Date.civil(params[:date_filter].values_at(:year, :month, :day))
# debugger
respond_to do |format|
format.html # map.html.erb
format.xml { render :xml => @its }
end
else
redirect_to '/'
@nearbylocations = Masterlocation.find(:all, :conditions => ["latitude > 25 AND latitude < 30 AND longitude > -75 AND longitude < -70", params[:id]], :order => ['nickname asc'])
end
繰り返しますが、私はあなたの助けに感謝します!