0
當我的評論下面的代碼未定義的方法'地圖」的零:在紅寶石NilClass在軌道上
<script type="text/javascript">
// var data1= "<%=[@properties.map {|c| {time:c.time.strftime("%H").to_i , speed:c.speed}}].to_json%>"
//var data=JSON.parse(data1.replace(/"/g,'"'));
//alert("dataset-------------------"+data);
</script>
以下錯誤showing.Why後我評論的code.While也刪除下面的錯誤意見出現此錯誤發生。
ActionView::Template::Error (undefined method `map' for nil:NilClass):
48: <div id="bar-demo" align="center">
49: <script type="text/javascript">
50:
51: // var data1= "<%=[@properties.map {|c| {time:c.time.strftime("%H").to_i , speed:c.speed}}].to_json%>"
52:
53:
54: //var data=JSON.parse(data1.replace(/"/g,'"'));
app/views/static_pages/show.html.erb:51:in `_app_views_static_pages_show_html_erb__413296487_31443192
'
yes我也糾正了問題。在頁面加載@properties將是nil.its包含值,只有當我從dropdown.when選擇一些數據時,我添加條件錯誤得到解決:-) – Psl 2013-03-22 04:35:08