Re: Validation without ActiveRecord

Carl Youngblood
Sat, 23 Jul 2005 22:42:12 -0000

Here is the controller code:

def searchreq
  @req = SearchRequest.new if @req.nil?
    if @req.valid?
      # I haven''t put anything in here yet
    end
end

Here is the model:

class SearchRequest < ValidatingBase
  attr_accessor :fullname, :email, :phone
  validates_presence_of :fullname, :email, :phone
end

In the form I''m just calling error_messages_for ''req''

ValidatingBase comes from the following wiki page:

http://wiki.rubyonrails.com/rails/show/HowToUseValidationsWithoutExtendingActiveRecord

So I''m actually not using ActiveRecord.

Thanks for your help.

Carl

On 7/23/05, Wilson <defiler-ifvz4xmYPRU@public.gmane.org>
wrote:
> Can we see the controller code for the action?
> Usually it''s because you''re assuming you got there from a
fresh page.
> You need to make sure you don''t make duplicate AR objects from
"params"
>
> Carl Youngblood wrote:
> > Okay, now I have another problem with my validations.  Every time I
> > submit the form it adds more errors to the list of validation errors.
> > The list has tons of duplicate errors.  Any ideas as to what might be
> > wrong?  I''m assuming that what it should do instead is just
keep
> > reloading the form with the same errors listed.
> >
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>