部署到Heroku时,Rails current_page会导致500错误

时间:2012-06-04 09:29:17

标签: ruby-on-rails-3 heroku internal-server-error current-page

我有一个导航菜单,如果链接或其任何子节点处于活动状态,我想突出显示这些链接。

我的菜单包含以下代码:

<ul>
            <li class="first <%= current_page?(controller: 'posts', action: params[:action]) ? 'current' : '' %>"><%= link_to "Blog", blog_path %></li>
            <li class="<%= current_page?(controller: 'organisations', action: params[:action]) ? 'current' : '' %>"><%= link_to "Organisations", organisations_path %></li>
            <li class="<%= current_page?(controller: 'events', action: params[:action]) ? 'current' : '' %>"><%= link_to "Events", events_path %></li>
            <li class="<%= current_page?(controller: 'pages', action: 'about') ? 'current' : '' %>"><%= link_to "About",    about_path %></li>
            <li class="<%= current_page?(controller: 'pages', action: 'contact') ? 'current' : '' %>"><%= link_to "Contact",    contact_path %></li>
            <% if user_signed_in? %>
                <li class="last <%= current_page?(controller: 'users', action: params[:action]) ? 'current' : '' %>">
                    <a href="#"><%= current_user.username %></a>
                    <ul>
                        <li class="first"><%= link_to "Your Account", users_control_panel_path %></li>
                        <li class="last"><%= link_to "Log out", destroy_user_session_path, method: "delete" %></li>
                    </il>
                </li>
            <% else %>
                <li class="last <%= current_page?(controller: 'devise/sessions', action: 'new') ? 'current' : '' %>"><%= link_to "Log in", new_user_session_path %></li>
            <% end %>
        </ul>

这在开发环境中没有问题。但是,当我推送到Heroku时,页面无法加载内部服务器错误。从日志中:

2012-06-04T09:17:10+00:00 app[web.1]: Started GET "/organisations" for 2.124.94.147 at 2012-06-04 09:17:10 +0000
2012-06-04T09:17:10+00:00 app[web.1]: Processing by OrganisationsController#index as HTML
2012-06-04T09:17:11+00:00 app[web.1]:   Rendered organisations/index.html.erb within layouts/application (103.1ms)
2012-06-04T09:17:11+00:00 app[web.1]:   Rendered layouts/_shim.html.erb (0.2ms)
2012-06-04T09:17:11+00:00 app[web.1]:   Rendered layouts/_head.html.erb (1.9ms)
2012-06-04T09:17:11+00:00 app[web.1]:   Rendered layouts/_header.html.erb (100.2ms)
2012-06-04T09:17:11+00:00 app[web.1]: Completed 500 Internal Server Error in 294ms
2012-06-04T09:17:11+00:00 app[web.1]: 
2012-06-04T09:17:11+00:00 app[web.1]: ActionController::RoutingError (No route matches {:controller=>"users"}):
2012-06-04T09:17:11+00:00 app[web.1]:   app/views/layouts/_header.html.erb:16:in `_app_views_layouts__header_html_erb___3404956210772716386_32718660'
2012-06-04T09:17:11+00:00 app[web.1]:   app/views/layouts/application.html.erb:10:in `_app_views_layouts_application_html_erb__4043808991853607868_39058420'

我最近从WEBrick变为Thin,无论是在Heroku还是本地。使用WEBrick时没有问题,并且本地不存在问题。问题是什么,还是有更好的方法来实现这个目标?

0 个答案:

没有答案