Rails 在开发模式下正常,在生产模式下提示我没有 photo_url 方法

tiseheaini · 2012年09月05日 · 最后由 tiseheaini 回复于 2012年09月05日 · 2020 次阅读

在开发模式下正常,在生产模式下提示我没有 photo_url 方法 是不是应该在配置文件下写些什么。

Started GET "/" for 127.0.0.1 at 2012-09-05 22:04:35 +0800
Processing by HomeController#index as HTML
  Rendered home/index.html.erb within layouts/application (101.1ms)
Completed 500 Internal Server Error in 186ms

ActionView::Template::Error (undefined method `photo_url' for nil:NilClass):
    13:             <% @topics.each do |topic| %>
    14:             <div class="feed-list">
    15:                 <div class="list-single">
    16:                         <div class="list-face"><%= link_to image_tag(topic.user.photo_url(:thumb))
    17:                             <div class="list-content">
    18:                                 <div class="user-title">
    19:                                    <div class="user-name"><%= link_to topic.title, topic_path(topi
  app/views/home/index.html.erb:16:in `block in _app_views_home_index_html_erb__317338617_80589530'
  app/views/home/index.html.erb:13:in `_app_views_home_index_html_erb__317338617_80589530'

是不是 topic 的 user 为 nil?数据不完整

#1 楼 @icesky 没有呀,我用 db:seed 写进了一些信息

#1 楼 @icesky 问题解决了,貌似是因为导入的数据有问题,谢谢帮忙

需要 登录 后方可回复, 如果你还没有账号请 注册新账号