|
[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
end
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),
Jason
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
/usr/lib/ruby/gems/1.8/gems/activerecord-1.12.2/lib/active_record/connection_adapters/mysql_adapter.rb:42:in
`real_connect'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.12.2/lib/active_record/connection_adapters/mysql_adapter.rb:42:in
`mysql_connection'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.12.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:120:in
`send'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.12.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:120:in
`connection_without_query_cache='
/usr/lib/ruby/gems/1.8/gems/activerecord-1.12.2/lib/active_record/query_cache.rb:54:in
`connection='
/usr/lib/ruby/gems/1.8/gems/activerecord-1.12.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:83:in
`retrieve_connection'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.12.2/lib/active_record/base.rb:243:in
`connection'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.12.2/lib/active_record/base.rb:708:in
`columns'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.12.2/lib/active_record/base.rb:1565:in
`attributes_from_column_definition'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.12.2/lib/active_record/base.rb:1104:in
`initialize_without_callbacks'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.12.2/lib/active_record/callbacks.rb:236:in
`initialize'
./script/../config/../app/controllers/send_email_controller.rb:5:in
`new'
./script/../config/../app/controllers/send_email_controller.rb:5:in
`send_email'
--- 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
http://mail.yahoo.com
_______________________________________________
talk mailing list
talk@phillyonrails.org
http://lists.phillyonrails.org/mailman/listinfo/talk
|
|