문제

In Development it works just fine, but on Production (Heroku), it breaks with the following Error.

The Error is actually in

<%= link_to clip.user.show.name, clip.user.show %>

The Error Log:

ActionView::Template::Error (undefined method `name' for nil:NilClass):
2013-09-02T10:24:09.366120+00:00 app[web.1]:     34:
2013-09-02T10:24:09.366120+00:00 app[web.1]:     35:   <p class="clip-uploader pull-left" data-no-turbolink>
2013-09-02T10:24:09.366120+00:00 app[web.1]:     36:     <strong>
2013-09-02T10:24:09.366120+00:00 app[web.1]:     37:       <%= link_to clip.user.show.name, clip.user.show %>
2013-09-02T10:24:09.366120+00:00 app[web.1]:     38:     </strong>
2013-09-02T10:24:09.366120+00:00 app[web.1]:     39:   </p>
2013-09-02T10:24:09.366120+00:00 app[web.1]:     40:
2013-09-02T10:24:09.366120+00:00 app[web.1]:   app/views/clips/_clip.html.erb:37:in `_app_views_clips__clip_html_erb_

Why does this brake on heroku ?

도움이 되었습니까?

해결책 2

The Solution was that i had 1 pre existing Clip in my Database from a very early version that had no show attached.

다른 팁

It clearly mentions that clip.user.show is not nil, that mean clip.user is not there in the database. If it can be nil for some values you can try this:-

<%if clip.user.show.present?%>
<%= link_to clip.user.show.name, clip.user.show %>
<%end%>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top