生产中的 Haml 渲染错误
我正在 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'
有什么明显的我做错了吗?
问候, 约翰
I'm writing a Rails 3 application on Mac OSX and it runs fine under both development and production. When I deploy the app with Passenger I get a error in one of my views. This is how the view looks like:
%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"
And this is the error I'm getting:
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'
Is there something obvious I'm doing wrong?
Regards,
Johann
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来第 4 行正在使用新的 Ruby 1.9 哈希语法
key: value
而不是:key =>值。您的生产环境运行的是 Ruby 1.8 吗?如果是这样,您需要升级到 1.9,或者使用 Ruby 1.8 兼容格式:
It looks like line #4 is using the new Ruby 1.9 hash syntax of
key: value
instead of:key => value
. Is your production environment running Ruby 1.8? If so, you'll either need to upgrade to 1.9, or use the Ruby 1.8 compatible format: