I''ve got a class that uses validation without inheriting from
ActiveRecord. It looks like this:
class SearchRequest < ValidatingBase
attr_accessor :fullname, :email, :phone
validates_presence_of :fullname, :email, :phone
def initialize(req)
req.each {|key, val| self.send(key + ''='', val) } if req
end
end
Its controller action looks like this:
def searchreq
@req = SearchRequest.new(params[:req])
if params[:req]
if @req.valid?
# send email
end
end
end
When I submit the form without the required parameters, it gives me
the following error:
3 errors prohibited this req from being saved
There were problems with the following fields:
* fullname can''t be blank
* phone can''t be blank
* email can''t be blank
I want the error message to say "request" instead of "req"
and give
human-readable names for the class accessors instead of their actual
variable names. Is there a way to do this?
Thanks,
Carl