[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Problem with login example in Agile Web Development with Ruby 2nd Edition

chhenning

1/16/2007 7:05:00 PM

Hi all, this is the first time I'm posting to this list or all Ruby on
Rails lists, at all. If I'm wrong here please let me know where the
best place is to put my question.

I'm doing the authentication example in the new Agile Development with
Rails book. For whatever reason the user login page doesn't work. The
login.rhtml looks like this:

<!--
! Excerpted from "Agile Web Development with Rails, 2nd Ed."
! We make no guarantees that this code is fit for any purpose.
! Visit http://www.pragmaticprogrammer.com/tit... for more book
information.
-->
<div class="depot-form">
<fieldset>
<legend>Please Log In</legend>

<% form_tag do %>
<p>
<label for="name">Name:</label>
<%= text_field_tag :name, params[:name] %>
</p>

<p>
<label for="password">Password:</label>
<%= password_field_tag :password, params[:password] %>
</p>

<p>
<%= submit_tag "Login" %>
</p>
<% end %>
</fieldset>
</div>

But when trying to display this site there aren't any input fields.
Seems to me the "form_tag do" does produce any html code. My Firefox
browser simply shows the following page source.

<html>
<head>
<title>Admin: login</title>
<link href="/stylesheets/scaffold.css?1168898602" media="screen"
rel="Stylesheet" type="text/css" />
</head>
<body>

<p style="color: green"></p>

<!--
! Excerpted from "Agile Web Development with Rails, 2nd Ed."
! We make no guarantees that this code is fit for any purpose.
! Visit http://www.pragmaticprogrammer.com/tit... for more book
information.
-->
<div class="depot-form">
<fieldset>
<legend>Please Log In</legend>


</fieldset>
</div>

</body>
</html>

Does anybody know what might be wrong with my application? Any hint is
very welcome. I'm in my first steps of using Ruby on Rails.

Thanks ahead,
Christian

5 Answers

Jano Svitok

1/16/2007 7:37:00 PM

0

On 1/16/07, chhenning <chhenning@gmail.com> wrote:
> Hi all, this is the first time I'm posting to this list or all Ruby on
> Rails lists, at all. If I'm wrong here please let me know where the
> best place is to put my question.

There is a google group specifically for Rails, so you might get
better help there.
> I'm doing the authentication example in the new Agile Development with
> Rails book. For whatever reason the user login page doesn't work. The
> login.rhtml looks like this:
>
> <!--
> ! Excerpted from "Agile Web Development with Rails, 2nd Ed."
> ! We make no guarantees that this code is fit for any purpose.
> ! Visit http://www.pragmaticprogrammer.com/tit... for more book
> information.
> -->
> <div class="depot-form">
> <fieldset>
> <legend>Please Log In</legend>
>
> <% form_tag do %>
> <p>
> <label for="name">Name:</label>
> <%= text_field_tag :name, params[:name] %>
> </p>
>
> <p>
> <label for="password">Password:</label>
> <%= password_field_tag :password, params[:password] %>
> </p>
>
> <p>
> <%= submit_tag "Login" %>
> </p>
> <% end %>
> </fieldset>
> </div>
>
> But when trying to display this site there aren't any input fields.
> Seems to me the "form_tag do" does produce any html code. My Firefox
> browser simply shows the following page source.

There is a new way to do this s seen here:
http://www.loudthinking.com/arc/0...

and old way seen here:
http://api.rubyonrails.com/classes/ActionView/Helpers/FormTagHelper.ht...

My action pack 1.12.5 seems to support just the old one.
api.rubyonrails.com knows nothing about the new one. Maybe this works
in development version (would be 1.2) only

So either change your script to use the old form, or install egderails
(I won't help you with this, I guess it involves getting rails
directly from SVN)

J.

Dave Thomas

1/16/2007 10:02:00 PM

0


On Jan 16, 2007, at 1:05 PM, chhenning wrote:

> Does anybody know what might be wrong with my application? Any hint is
> very welcome. I'm in my first steps of using Ruby on Rails.


Did you install the version of Rails cited inside the book's front
cover, and run rake rails:update?


Dave

gmarik

1/17/2007 9:34:00 AM

0


chhenning wrote:
> <% form_tag do %>

> Does anybody know what might be wrong with my application? Any hint is
> very welcome. I'm in my first steps of using Ruby on Rails.
Didn't you forget = in the construction above? So it should look
like:
<%= form_tag do %>
....

Jano Svitok

1/17/2007 9:42:00 AM

0

On 1/17/07, gmarik <gmarik@gmail.com> wrote:
>
> chhenning wrote:
> > <% form_tag do %>
>
> > Does anybody know what might be wrong with my application? Any hint is
> > very welcome. I'm in my first steps of using Ruby on Rails.
> Didn't you forget = in the construction above? So it should look
> like:
> <%= form_tag do %>
> ...

No. See DHH's blog. You either use = or do...end (if you have 1.2) and
= without block in 1.0. See
lib/actionpack/actionview/tag_form_helper.rb

Dave Thomas

1/17/2007 2:31:00 PM

0


On Jan 17, 2007, at 3:35 AM, gmarik wrote:

> chhenning wrote:
>> <% form_tag do %>
>
>> Does anybody know what might be wrong with my application? Any
>> hint is
>> very welcome. I'm in my first steps of using Ruby on Rails.
> Didn't you forget = in the construction above? So it should look
> like:
> <%= form_tag do %>
> ...


No, that form is what should be used in 1.2. It works as long as
you're running a 1.2 RC, or the code .zip file provided with the book.


Dave