Jason Lenhart on 7 Feb 2006 03:08:40 -0000

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PhillyOnRails] Simple Form Validation Example

First off -- thank you very much for your help.

I tried this but I got a bad Application Trace (I
guess this is the equivalent to a Java Stack Trace) --
see below.

Note that I made some changes where my html form has
tags like the following:

Your name<br><%= text_field("contact", "realname",
"class" => "field") %>

my controller looks like this:

contact = Contact.new(params[:contact])

and the contact.rb:

class Contact < ActiveRecord::Base

I believe that my contact.rb is lacking ... but the
error is due to trying to go to the database - where I
am not looking to do that.

Thanks -- I have this working in my examples from
online (but they goto the database),


Can't connect to local MySQL server through socket
'/path/to/your/mysql.sock' (2)
RAILS_ROOT: script/../config/..

Application Trace | Framework Trace | Full Trace

--- Tom Lieber <alltom@gmail.com> wrote:

> On 2/5/06, Jason Lenhart <jplenhart@yahoo.com>
> wrote:
> > I have a form being populated and have used the
> > following:
> >
> > <%= text_field("user", "name", "class" => "field")
> %>
> >
> > Note that my user model class is not going to a
> > database via scaffold - just a class in my models
> > directory.
> >
> > When the form is submitted I cannot find a way to
> get
> > a handle on the populated user model object.  I
> dug
> > through my Rails book to no avail - did not see
> any
> > straightforward ways of doing this.
> Typically, in your controller, for the action to
> which the form is
> submitted, you will have a line like this:
>     @user = User.new(@params[:user])
> When you write text_field("user", "name"), what
> you're saying is
> "display a field for the parameter 'name' of the
> object @user". Thus,
> by creating the object this way, the object @user
> will have the data
> from the last form submission at all times. This is
> how, when you use
> a scaffold, forms retain all of your entered values
> when there is an
> error and the form is redisplayed. When there is no
> @user created in
> this way, the form will be cleared after every
> request.
> > Also - should I be declaring the instance
> varialbles
> > in my user object any special way?
> Instance variables in models can be used normally,
> and without being
> too careful, you can avoid conflicting with any of
> the ActiveRecord
> stuff.
> > Thanks for any help that can be offered,
> > Jason
> Sincerely,
> Tom Lieber
> http://AllTom.com/
> http://GadgetLife.org/
> _______________________________________________
> talk mailing list
> talk@phillyonrails.org
> http://lists.phillyonrails.org/mailman/listinfo/talk

Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
talk mailing list