Skip to content

Instantly share code, notes, and snippets.

@elentras
Created November 14, 2012 09:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elentras/4071146 to your computer and use it in GitHub Desktop.
Save elentras/4071146 to your computer and use it in GitHub Desktop.
My index file : Triing to apply simplify render in views (best practice)
<div class="article" data-ref="<%= article.id %>" data-text="<%= article.synopsis? %>" data-video="<%= article.video? %>">
<div class="img">
<%= image_tag(article.image.url(:panorama), :class => 'color') %>
</div>
</div>
<div id="contenu" class="contenu small">
<div class="grid inner-contenu">
<div class="c960">
<%= render 'article', :collection => @articles %>
</div>
</div>
</div>
RuntimeError in Articles#index
Showing /Users/stagiaire/Projects/vodmania/app/views/articles/_article.html.erb where line #1 raised:
Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id
Extracted source (around line #1):
1: <div class="article" data-on="false" data-ref="<%= article.id %>" data-text="<%= article.has?(:synopsis) %>" data-video="<%= article.has_video? %>">
2: <div class="img">
3: <%= image_tag(article.image.url(:panorama), :class => 'color') %>
4: <%= image_tag(article.image.url(:panorama_black), :class => 'black') %>
Trace of template inclusion: app/views/articles/index.html.erb
@elentras
Copy link
Author

In the index file, replacing render by :

<%= render @articles %>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment