correction....
<%= render partial: 'news/news', locals: { news: test_news_last } %>.
On Tuesday, June 9, 2015 at 9:28:23 AM UTC-4, Elizabeth McGurty wrote:
>
> One possibility:
> <% test_news_last = News.last %>
> <% unless test_news_last .blank? %>
> <%= render partial: 'news/news', locals: { news: News.last } %>.
> <% else %>
> <div>Sorry but not results were found.</div> #However you want to
> display message
> <% end %>
>
> Another, is that you do similar test in the partial itself
>
> And, Colin is entirely correct that you should rename your models(.rb) to
> singular, while table names are plural on your database. Then model class
> name should be singular as well, however proper case, replacing event of
> "_" in model name with ommitted "_" and then first letter capitalized.
> Another consideration is that primary keys should be 'id', while foreign
> keys should be 'lower-case_singular model name'_id. This will make a huge
> difference if you attempt to use table associations.
>
>
>
>
>
>
> On Thursday, June 4, 2015 at 6:11:30 AM UTC-4, Ruby-Forum.com User wrote:
>>
>> This could possibly be a really stupid question, but I have a home page
>> which calls a partial to show the latest entry in a table called 'news'.
>> All I want to know is how to put the 'news.content' into a text box.
>> Partial is as follows:
>>
>> <p>
>> <strong>Title:</strong>
>> <%= news.title %>
>>
>> </p>
>>
>> <p>
>> <strong>Details:</strong>
>> <%= news.content %>
>> </p>
>>
>>
>> The bit that calls this on my home page is as such:
>>
>> <%= render partial: 'news/news', locals: { news: News.last } %>.
>>
>> --
>> 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 [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/250f59d0-703e-4e28-8e10-75827b679850%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.