On 8 June 2015 at 17:02, Euan Leslie <[email protected]> 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

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLsdbcG6g91GXuDx5_oBfSHFsrZB%3DzXMrNrJx9uzsnwSDQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to