Re: Validation without ActiveRecord

Trevor Squires
Mon, 25 Jul 2005 09:06:44 -0000

Hi Carl,

I''ve seen the "accumulating errors" problem during
error_messages_for
once before while helping someone on IRC to use ValidatingBase.

In the end it was that he had put the ValidatingBase class in a file
called "validatingbase.rb" rather than the (correct)
"validating_base.rb".

Regards,
Trevor

On 23-Jul-05, at 11:42 PM, Carl Youngblood wrote:

> 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
>>
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails