Colin Law wrote in post #1174741:
> 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

Hi Colin

Thanks for that, but could you be a bit more specific please?  If all I 
need is a couple of words in a single line of code it would be better 
for someone to just tell me exactly what is required.

I've worked through quite a few tutorials and have learned a lot from 
them, but when wee things like this crop up I just want an answer 
straight away instead of working my way through a tutorial on the off 
chance that it may mention the thing I want to know about.

-- 
Posted via http://www.ruby-forum.com/.

-- 
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 rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/d84aef750e1103e5b088d44abb763afd%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to