Loop not rendering anything


#1

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| %>


<%= link_to s.show_time, :controller => “movies”, :action =>
“detail”, :id => s %>
<% end %>

Thanks for any help :frowning:


#2

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| %>


<%= 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