简体   繁体   English

导航管理界面时,我的实时应用出现错误

[英]Error in my live app when navigating admin interface

When I navigate to a certain resource in the admin interface for my app I get a status 500 error. 当我在应用程序的管理界面中导航到某个资源时,出现状态500错误。 Why might this be? 为什么会这样呢?

Here is from my logs: 这是我的日志:

2011-06-16T21:33:35+00:00 app[web.1]: Started GET "/admin/timeline_events" for 151.205.162.106 at 2011-06-16 14:33:35 -0700
2011-06-16T21:33:35+00:00 app[web.1]: 
2011-06-16T21:33:35+00:00 app[web.1]: NoMethodError (undefined method `map' for nil:NilClass):

How would I find where map is in my app? 我如何找到map在我的应用程序中的位置?

OK, so I think it's this code in my application helper that might be causing this 好的,所以我认为可能是应用程序帮助程序中的这段代码导致了

def render_timeline(events, title)
  events.map do |event|
    render(:partial => "timeline_events/#{event.event_type}", :locals => {:event => event, :title => title})
  end.join.html_safe
end

The code basically renders different partials depending on what type of event it is to create a feed. 该代码基本上根据创建提要的事件类型来呈现不同的部分。

It looks like you're calling the method but passing nil as the events argument. 看起来您正在调用方法,但是将nil作为events参数传递。

Make sure that when there are no events to be rendered, you pass in an empty array instead of nil . 确保在没有要呈现的事件时,传入一个空数组而不是nil

You can catch this in the body of the method by adding: 您可以通过添加以下内容在方法的主体中捕获该信息:

events ||= []

as the first line, or you can use default arguments: 作为第一行,或者您可以使用默认参数:

def render_timeline(events = [], title)

or you can just change how you generate the events argument so it never returns nil . 或者您可以更改events参数的生成方式,使其永远不会返回nil

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Rails应用程序中导航时jQuery不执行 - jQuery not executing when navigating within rails app 为什么我的 Heroku 应用程序在我实时推送 master.key 时崩溃? - Why is my Heroku app crashing when I push master.key live? 尝试部署我的应用程序时出错 - Error when trying to deploy my app 在Rails应用程序中为管理界面定义单独的视图和资产 - Defining separate views and assets for admin interface in a Rails app Active Admin在我的应用程序中after_sign_in_path_for(设计)登录时遇到问题 - Active Admin is having problems signing in when after_sign_in_path_for (devise) in my app 管理控制台:为我的应用生成用户列表? - Admin panel: generate list of users for my app? 如何将rails_admin放入我的应用程序 - How to fit rails_admin into my app Active Admin非常适合日常交易Rails 3.2应用程序的复杂管理界面吗? - Is active Admin a good fit for a complex admin interface for a daily deal rails 3.2 app? 我的JavaScript应该放在我的Rails 4应用程序中的什么位置 - Where should my javascript live in my Rails 4 app 如果current_user.admin看到&lt;%,Rails应用程序给出“没有方法错误”。 %&gt; - Rails app gives “no method error” when it sees <% if current_user.admin? %>
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM