我正在Mac OSX上编写一个Rails 3应用程序,它在开发和生产下运行良好。当我使用Passenger部署应用程序时,我的一个视图中出现错误。这就是视图的样子:
%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'
有什么明显的东西我做错了吗?
此致 约翰
答案 0 :(得分:2)
第4行似乎使用key: value
而不是:key => value
的新Ruby 1.9哈希语法。您的生产环境是否运行Ruby 1.8?如果是这样,您将需要升级到1.9,或使用Ruby 1.8兼容格式:
= link_to 'New area', '#', :id => "createNewAreaLink"