On 8 June 2015 at 17:02, Euan Leslie <
li...@ruby-forum.com> wrote:
> ...
> I've found another problem with this. It produces an error if there are
> no records in the table.
>
> The line in my Index view:
>
> <%= render partial: 'news/news', locals: { news: News.last } %>
>
> Can I make it just shows a blank entry if there is no record?
Just test for News.last nil, either in the render call or inside the
partial (inside the partial you would test for news nil of course.
The fact that you needed to ask this makes me think you would benefit
from working right through a good tutorial such as
railstutorial.org
(which is free to use online), including doing all the exercises. A
few days spent doing that would very soon be recovered.
Colin