Nov 20, 2007
Generic-user-small Keyton Weiss... 1 post

Topic: Agile Web Development with Rails / Blocks in Views (Newbie)

OK. So I’m a noob in both Rails and Ruby—but I’m trying to migrate and approach the code from a Ruby perspective.

As such, in the Instant Gratification Fun Time section, I tried the following (to do a bit better in the “looks like Ruby” category than the example):

<% if @files %>
    <h1>Files or Directories 2</h1>
    <ul>
      <%= @files.each {|file|}%>
    </ul>
    <% end %>

OK. No problem. That works. I get (or similar) in the resulting HTML:
Files or Directories 2
appcomponentsconfigdbdocliblogpublicRakefileREADMEscripttesttmpvendor

But if I want to add a little markup:

    <% if @files %>
    <h1>Files or Directories 2</h1>
    <ul>
      <%= @files.each {|file| puts '<li>'+file+'</li><br/>'}%>
    </ul>
    <% end %>

I get the exact same thing in my resulting HTML page (i.e. no markup):
Files or Directories 2
appcomponentsconfigdbdocliblogpublicRakefileREADMEscripttesttmpvendor

I’ve tried it in IRb to make sure the Ruby itself acts the way I think it should (and to make sure I wasn’t making a stupid Ruby mistake). But that worked fine.

What up?

Thanks in advance.

Keyton Weissinger

1 post