生产中的 Haml 渲染错误

发布于 2024-12-03 22:33:21 字数 1721 浏览 2 评论 0原文

我正在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

如此安好 2024-12-10 22:33:21

看起来第 4 行正在使用新的 Ruby 1.9 哈希语法 key: value 而不是 :key =>值。您的生产环境运行的是 Ruby 1.8 吗?如果是这样,您需要升级到 1.9,或者使用 Ruby 1.8 兼容格式:

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

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:

  = link_to 'New area', '#', :id => "createNewAreaLink"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文