Thufir wrote:
> def report
> reports = []
> calls.each do |call|
> puts login + "\t" +
> call.created_at.to_s + "\t"
> call.comment
> end
> end
After fixing this, you need to just sit and read a Ruby tutorial. Don't
just read to answer your current question; you need soak-time with this
stuff to get the hang of it.
In Rails (which this is not the best forum for), 'puts' never goes into a
web page. It always goes into the console, which is somewhere inside your
web server.
Next, Ruby uses a "magic return" system, where the return value of a
function is the return of its last block. 'calls.each' returns 'calls',
for method-chaining (look that up). You need to make a 'map' of report
contents, then 'join' them together, like this:
def report
return calls.map{ |call|
CGI::escapeHTML(login) + "\t" +
call.created_at.to_s + "\t"
CGI::escapeHTML(call.comment)
}.join('
')
end
Note that I added a clear 'return' (I always do), and that I used 2-space
tabs. Your editor picks 8 because it is stupid.
Use that like this:
> <% @login.report.each do |report| %>
> <%= report %>
> <% end %>
Notice I took your h out, because your system needed to escape your data
in between outputting your
.
You also need to read up on basic HTML. _All_ the Rails documentation
will assume you know you can't use "\t" in a web page!
--
Phlip