Forum: Ruby on Rails Development Web Server Producing mal-formed html

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.
Tim B. (Guest)
on 2009-01-15 04:30
I am struggling with differing html rendered by my development servers
on my Ubuntu 8.10 development environment. I have tried the following
case study with both mongrel and webrick, so I don't think the problem
is with the server.

While reducing this problem down to more simple case study would help,
the following code demonstrates my problem. Essentially, extra html
tags are being added and items are inserted inside <div> tags. I
imagine that rails rendering is causing this.

A view calls the following partial:

## partial

<div class="floatLeft width25">
  <blockquote>To register for a camp,
  click on the desired time-slot located at
  the bottom of each camp's description.</blockquote>
  <% hidden_div_if(@cart.items.empty?, :id => "cart") do %>
  <%= render(:partial => "cart", :object => @cart) %>
  <% end %>
</div>
<div class="floatRight width75">
  <h1>Register for a <span class="dark">Fitness Camp</span></h1>
  <dl>
    <% @fitness_camps.each do |fc| %>
    <dt><%= fc.full_title %><dt>
    <dd>
      <%= "#{fc.description}<br />" unless fc.description.nil? -%>
      Location: <%= link_to fc.location.name_in_context,
        :controller => 'location_info',
        :action => 'description',
        :id => fc.location.id %><br />
      <!-- NOW LIST TIME SLOTS -->
      <% fc.time_slots.each do |time_slot| %>
      <div style="float:left;padding-top:10px;">
        <% form_remote_tag :url => { :action => :add_to_cart,
            :id => time_slot },
            :html => {:id => "form#{time_slot.id}"}  do %>
          <%= submit_tag(time_slot.start_to_finish,
            :id => "reg_#{time_slot.id}",
            :class => 'button')  %>
        <% end # form_remote_tag %>
      </div><!-- for time slot end -->
      <% end # time slots iteration %>
      <div style="clear:both"><!-- clear div --></div>
       eieio
    </dd>
    <% end %>
  </dl>
</div><!-- main float -->

## which produces the following html (with the proper html tag
   indentation) (note that the test text eieio doesn't even show up
below)

<div class="floatRight width75">
  <h1>Register for a <span class="dark">Fitness Camp</span></h1>
  <dl>
    <dt>Camp 1 from 15 Mar 09 to 15 Sep 09<dt>
    <dd>camp 1 description<br />
    Location: <a href="/location_info/description/1">Location 1
Description</a><br />
    <!-- NOW LIST TIME SLOTS -->
    <div style="float:left;padding-top:10px;">
      <form action="" . . . deleted
      <div style="margin:0;padding:0">
        <input name="authenticity_token" type="hidden" value="..." />
      </div>
      <input class="button" id="reg_5" name="commit" type="submit"
value=" 11:00AM to 1:00PM" />
    </form>
    <div style="float:left;padding-top:10px;">
      <form action= . . . deleted for brevity
        <div style="margin:0;padding:0"><input name="authenticity_token"
type="hidden" value="..." />
        </div>
        <input class="button" id="reg_6" name="commit" type="submit"
value="2:00PM to 4:00PM" />
      </form>
      <dt>Camp 2 from 15 Dec 08 to 27 Dec 08<dt>
      <dd>description for camp 2 . . .<br />Location: <a
href="/location_info/description/1">Location 1</a><br />
      <!-- NOW LIST TIME SLOTS -->
      <div style="float:left;padding-top:10px;">
        <form action=
          <div style="margin:0;padding:0">
            <input name="authenticity_token" type="hidden" value="..."
/>
          </div>
          <input class="button" id="reg_1" name="commit" type="submit"
value="6:00AM to 8:00AM" />
        </form>
        <div style="float:left;padding-top:10px;">
          <form action=". . . deleted for brevity"
                <div style="margin:0;padding:0">
                  <input name="authenticity_token" type="hidden"
value="..." />
                </div>
                <input class="button" id="reg_2" name="commit"
type="submit" value="9:00AM to  10:00AM" />
              </form>
              <dt>Camp 3 from 14 Dec 08 to 31 Dec 08<dt>
              <dd>desc . . .<br />
              Location: <a href="/location_info/description/1">Location
1</a><br />
              <!-- NOW LIST TIME SLOTS -->
              <div style="float:left;padding-top:10px;">
                <form action=". . . .deleted"
                      <div style="margin:0;padding:0">
                        <input name="authenticity_token" type="hidden"
value="..." />
                      </div>
                      <input class="button" id="reg_3" name="commit"
type="submit" value="9:00AM to  10:00AM" />
                    </form>
                    <div style="float:left;padding-top:10px;">
                      <form action="" . . . deleted
                      <div style="margin:0;padding:0"><input
name="authenticity_token" type="hidden" value="..." />
                      </div>
                      <input class="button" id="reg_4" name="commit"
type="submit" value="2:00PM to 4:00PM" />
                    </form>
                  </dl>
                </div><!-- main float -->
              </div>


Sorry for all the code, but I wanted to show exactly what was being
generated. I particularly I am worried about how the <div> elements are
not closing. This is not the case with my production server using
apache + mongrel. What I suspect is that whatever component of rails
that is rendering the html is going off on some distracting direction.

Thank you for any help and let me know if this might be a rails bug
and if I should dig deeper into the rails code.
This topic is locked and can not be replied to.