Pregunta

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 ?

¿Fue útil?

Solución 2

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

Otros consejos

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%>
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top