Heroku current_page?休息

时间:2012-06-14 07:06:35

标签: ruby-on-rails layout heroku

我已经尝试了一切,但我未能解决这个问题,所以我来到了这里:)。我有以下工作在当地完美,但由于某种原因,当我把它推到heroku时,它会中断。

我的application.html.haml模板:

%body
    = render :partial => 'layouts/topbar'
    - if user_signed_in?
      - if current_page?(url_for(:controller => 'posts', :action => 'index'))
        = render :partial => "layouts/flash_messages", :locals => {:flash => flash}
        = yield
        #go-top
          Scroll to Top
      - else
        .container.main
          = render :partial => "layouts/flash_messages", :locals => {:flash => flash}
          = yield
    - else
      .container.main
        = render :partial => "layouts/flash_messages", :locals => {:flash => flash}
        = yield

有人可以指出我的错误吗?或者知道为什么这在heroku中打破?提前谢谢。

编辑:

我正在使用雪松堆栈应用程序,并且在我的heroku日志中,尽管该路径确实存在:

2012-06-14T08:39:59+00:00 app[web.1]: Started GET "/user_root" for XXX.XX.XXX.XX at 2012-06-14 08:39:59 +0000
2012-06-14T08:39:59+00:00 app[web.1]: ActionController::RoutingError (No route matches {:controller=>"posts"}):
2012-06-14T08:39:59+00:00 app[web.1]:   app/views/layouts/application.html.haml:27:in `_app_views_layouts_application_html_haml___40461595758832869_62063220'
2012-06-14T08:39:59+00:00 app[web.1]: Processing by HomeController#index as HTML
2012-06-14T08:39:59+00:00 app[web.1]: 
2012-06-14T08:39:59+00:00 app[web.1]:   Rendered layouts/_topbar.html.haml (3.6ms)
2012-06-14T08:39:59+00:00 app[web.1]: 
2012-06-14T08:39:59+00:00 app[web.1]: cache: [GET /user_root] miss
2012-06-14T08:39:59+00:00 app[web.1]:   Rendered home/index.html.haml within layouts/application (1.0ms)
2012-06-14T08:39:59+00:00 app[web.1]: Completed 500 Internal Server Error in 15ms

2 个答案:

答案 0 :(得分:1)

“heroku运行rake路线”并确保实际存在与以下路线相对应的路线:controller => “posts”和:action => “索引”。

不知道为什么在两台机器上的工作方式不同,但您也可以比较本地运行的“rake routes”。如果不明显,可能值得将输出添加到您的问题中。

答案 1 :(得分:0)

根据docs你不需要url_for部分吗?

尝试:

if current_page?(:controller => 'posts', :action => 'index')