Compile error question on a login.rhtml file (text included)

I am working my way through the January 2007 edition of "Build Your
Own Ruby on Rails Web Applications" by Patrick Lenz. The application
in the book is a clone of digg.com and I am halfway through the book
with no problems.

I am now working on the user authentication portion, and I am getting
a compile error with the following 12 line file (typed exactly as
printed in the book):

<% form_tag do %>
  <p>Please log in.</p>
  <p>
    <label>Username:</label>
    <%= text_field_tag 'login' %>
  </p>
  <p>
    <label>Password:</label>
    <%= password_field_tag 'password' %>
  </p>
  <p><%= submit_tag 'login' %></p>
<% end_form %>

The compile error is:

compile error
C:/CONDUC~1/rails_apps/shovell/config/../app/views/account/login.rhtml:
13: parse error, unexpected $, expecting kEND

Extracted source (around line #13):

10: </p>
11: <p><%= submit_tag 'login' %></p>
12: <% end_form %>

My application's environment is:

Ruby version 1.8.5 (i386-mswin32)
RubyGems version 0.9.2
Rails version 1.2.3
Active Record version 1.15.3
Action Pack version 1.13.3
Action Web Service version 1.2.3
Action Mailer version 1.3.3
Active Support version 1.4.2
Application root C:/CONDUC~1/rails_apps/shovell
Environment development
Database adapter mysql
Database schema version 4

I suspect that I have a typo somewhere, but I need a fresh set of eyes
to review what I have typed to uncover it. I realize that there might
be a version differential between what I have installed on my laptop
and the version used in the book (Ruby 1.8.4, Rails 1.2 Release
Candidate 2, MySQL General Release 5.0.27).

Thanks in advance for your guidance!

John

You have two different approaches to building form mixed up here. If you’re starting a form with

<% form_tag do %>

then you need

<% end %>

to match the ‘do’. (everything between them is considered a block. So your form should be:

<% form_tag do %>

Please log in.

Username:

<%= text_field_tag ‘login’ %>

Password:

<%= password_field_tag ‘password’ %>

<%= submit_tag 'login' %>

<% end %>

For more, look at the form_tag API documentation at:

http://rails.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html#M000601

James.

You have two different approaches to building form mixed up here. If
you're starting a form with

<% form_tag do %>

then you need

<% end %>

to match the 'do'. (everything between them is considered a block. So
your form should be:

<% form_tag do %>
   <p>Please log in.</p>
   <p>
     <label>Username:</label>
     <%= text_field_tag 'login' %>
   </p>
   <p>
     <label>Password:</label>
     <%= password_field_tag 'password' %>
   </p>
   <p><%= submit_tag 'login' %></p>
<% end %>

For more, look at the form_tag API documentation at:

http://rails.rubyonrails.org/classes/ActionView/Helpers/
FormTagHelper.html#M000601

James.

--
James Stewart
Play:http://james.anthropiccollective.org
Work:http://jystewart.net/process/

James,

Thank you for clarifying that point and providing the online reference
resource as well! I made the change and it worked instantly. This is
my first efforts at Ruby on Rails (and programming in general) with a
mountain of things to learn. I hope to arrive at a point of
proficiency where I can contribute similar guidance to another newbie
in the near future.

Thanks again!

John