Forum: Ruby on Rails Loop not rendering anything

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Daniel S. (Guest)
on 2007-05-03 06:38
(Received via mailing list)
I have a database that is reading the "show_times" from a column in my
database table, but nothing is showing up. Is there some sort of
syntax error here? I thought this was working fine yesterday...


<% @show_times.each do |s| %>
    <br/>
    <%= link_to s.show_time, :controller => "movies", :action =>
"detail", :id => s %>
 <% end %>


Thanks for any help :(
shai (Guest)
on 2007-05-03 11:46
Daniel Scrima wrote:
> I have a database that is reading the "show_times" from a column in my
> database table, but nothing is showing up. Is there some sort of
> syntax error here? I thought this was working fine yesterday...
>
>
> <% @show_times.each do |s| %>
>     <br/>
>     <%= link_to s.show_time, :controller => "movies", :action =>
> "detail", :id => s %>
>  <% end %>
>
>
> Thanks for any help

Hey daniel -

if the loop isn't rendering anything, but there is no error either - one
of two options is the case:

 either 1) @show_times is an empty array
                 # @show_times.inspect ==> []
 or     2) a show_time instance with the show_time method returns an
empty string
                 # s.show_time => ""

that's my guess.
the best thing to do, as a first debugging step is to use #inspect -
great debugging tool. just do:

   @show_times.inspect in the rhtml (or in the action in the controller
do render_text @show_times.inspect on the last line)

and see what it comes up with. i find this very useful.
good luck!

-shai
This topic is locked and can not be replied to.