Re: Validation without ActiveRecord

Wilson
Sat, 23 Jul 2005 06:11:51 -0000

text_field requires that the first parameter be the string
representation of an instance variable name.
In your controller, you should call the "request" method and make an
instance variable called "@request" with it.
Then you can use <%= text_field ''request'',
''fullname'' %>

(You may want to rename it, as well. The error message implies that
there''s a potential name conflict.)

--Wilson.

Carl Youngblood wrote:
> Hello, I followed the instructions at
>
>
http://wiki.rubyonrails.com/rails/show/HowToUseValidationsWithoutExtendingActiveRecord
>
> But now I''m having trouble trying to create my form view.
Here''s a
> brief rundown of what I''ve done:
>
> - Created a class called SearchRequest that extends ValidatingBase and
> saved it in a file called search_request.rb and put it in my models
> directory.
> - Added a ''request'' method to my controller that
instantiates
> SearchRequest and calls the valid? method
> - Created a view called request.rhtml and saved it into app/views/home.
>
> Even though my SearchRequest class has an accessor called fullname, I
> get a NoMethodError exception when I try to call
>
> <%= text_field :request, ''fullname'' %>
>
> It says:
>
> undefined method `fullname'' for
#<ActionController::CgiRequest:0x24a6c14>
>
> I''m assuming that my controller somehow has not figured out that I
> want to use SearchRequest as my model.  I tried adding it as a model
> to the controller but that didn''t fix this  problem.
>
> Any advice would be greatly appreciated.
>