2011-09-10 80 views
1

我正在Mac OSX上編寫Rails 3應用程序,它在開發和生產環境下運行良好。當我使用Passenger部署應用程序時,在我的某個視圖中出現錯誤。這是該視圖的樣子:Haml渲染生產出錯

%p#refresh= link_to 'Refresh', '#', id: "refreshAreaLink" 

#newAreaParagraph 
    = link_to 'New area', '#', id: "createNewAreaLink" 

- for area_group in AreaGroup.all 
    .areaGroup 
    = area_group.name 
    %ul 
    - for area in Area.find_all_by_area_group_id(area_group.id) 
    %li.areaList 
     = link_to area.name, area, :remote => true, :class => "areaLink", :id => "prufa" 
.areaGroup 
    No group 
- for area in Area.find_all_by_area_group_id(nil) 
    %li.areaList 
    = link_to area.name, area, :remote => true, :class => "areaLink", :id => "prufa" 

這是我得到的錯誤:

Started GET "/" for 192.168.102.28 at Sat Sep 10 15:36:20 +0000 2011 
    Processing by MapController#index as HTML 
Rendered areas/_sidebar.html.haml (4.9ms) 
Rendered map/index.html.haml within layouts/map (7.8ms) 
Completed in 224ms 

ActionView::Template::Error (compile error 
/var/shellopt/app/views/areas/_sidebar.html.haml:1: syntax error, unexpected ':', expecting ')' 
...e((link_to 'Refresh', '#', id: "refreshAreaLink" 
          ^
/var/shellopt/app/views/areas/_sidebar.html.haml:4: syntax error, unexpected ':', expecting ')' 
...(link_to 'New area', '#', id: "createNewAreaLink" 
           ^): 
    1: %p#refresh= link_to 'Refresh', '#', id: "refreshAreaLink" 
    2: 
    3: #newAreaParagraph 
    4: = link_to 'New area', '#', id: "createNewAreaLink" 
    app/views/areas/_sidebar.html.haml:22:in `compile' 
    app/views/layouts/map.html.haml:24:in `_app_views_layouts_map_html_haml___245337611_70182228267100_0' 

有什麼明顯的,我做錯了什麼?

問候, 約翰

回答

2

它看起來像4號線使用的key: value代替:key => value新的Ruby 1.9的哈希語法。您的生產環境是否運行Ruby 1.8?如果是這樣,你需要升級到1.9,或者使用Ruby 1.8兼容格式:

= link_to 'New area', '#', :id => "createNewAreaLink" 
+0

正確 - 我在生產中使用1.8.x, 。對我來說,下一步是更新生產中的紅寶石版本。非常感謝Dylan。 – gugguson