How to properly debug?

M

miriamraphael

I am writing my first rails script and am having lots of trouble doing
the simplest tasks.
Right now, I have a form (new.rhtml) and it allows someone to become a
new user by entering their info (username, password, name, etc).

the form calls the 'create' routine which is supposed to save it to
the DB. However, the data is not being saved. How can I debug this? I
am a perl scripter and with Perl I know how to find out where the bugs
are, but because I'm new to ruby/rails, I can't figure this out.

Here is the form:

<form action="/user/create" method="post">
<table width=400>
<tr bgcolor="#999999"><td colspan=2>Please choose a username and
password to create your account</tr>

<tr><td>User Name*:</td><td><input id="username" name="user[username]"
maxlength=12 type=text></tr>
<tr><td>Password*:</td><td><input id="password" name="user[password]"
maxlength=12 type=password></tr>

<tr bgcolor="#999999"><td colspan=2>Account Information</td></tr>
<tr><td>Company Name*:</td><td><input id="company_name"
name="user[company_name]" maxlength=25 type=text></td></tr>
<tr><td>First Name*:</td><td><input id="first_name"
name="user[first_name]" maxlength=25 type=text></td></tr>
<tr><td>Last Name*:</td><td><input id="last_name"
name="user[last_name]" maxlength=25 type=text></td></tr>
<tr><td>Email Address*:</td><td><input id="email" name="user(e-mail address removed)
 
E

Edward Faulkner

--Qxx1br4bt0+wmkIi
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

I am writing my first rails script and am having lots of trouble doing
the simplest tasks.

I don't see anything obviously wrong. But here are two debugging
suggestions:

1. Look in log/development.log

2. Try running the environment in a console and creating a new record
"by hand":

$ ruby script/console development
Loading development environment.
And finally, try asking your question on the Rails mailing list.
You'll get better support there.

regards,
Ed

--Qxx1br4bt0+wmkIi
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFDjbcdnhUz11p9MSARAmgHAJsEgoHMnlFx+jfLpAWwNpAOVBUx5wCdGjVh
kOMnKFUiyhxGBIEwgVIFxbw=
=ILwJ
-----END PGP SIGNATURE-----

--Qxx1br4bt0+wmkIi--
 
F

Florian Groß

I am writing my first rails script and am having lots of trouble doing
the simplest tasks.
Right now, I have a form (new.rhtml) and it allows someone to become a
new user by entering their info (username, password, name, etc).

Use .save! instead of .save.

save returns false on failure, .save! raises an Exception.
 
W

Wilson Bilkovich

Yeah, or my preferred pattern:

unless user.valid?
flash[:error] =3D "Possibly something custom"
redirect or render something
return
end
user.save

Actually, now that I've written that out, maybe save! and rescue is more co=
mpact

user.save!
rescue WhateverThatExceptionIsCalled =3D> e
redirect_somewhere
end
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,008
Latest member
HaroldDark

Latest Threads

Top