# Access form submitted values inside model class

**URL:** <https://www.ruby-forum.com/t/access-form-submitted-values-inside-model-class/127023>\
**Category:** Rails\
**Created:** [January 24, 2008, 10:11am UTC](https://www.ruby-forum.com/t/access-form-submitted-values-inside-model-class/127023 "2008-01-24T10:11:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Penuel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/278dde/32.png) [@Penuel](https://www.ruby-forum.com/u/Penuel)\
**Post date:** [January 24, 2008, 10:11am UTC](https://www.ruby-forum.com/t/access-form-submitted-values-inside-model-class/127023/1 "2008-01-24T10:11:26Z")

</div>

Hi All,

I am sure some one of you might have faced this. I am trying to  
validate the user submitted values inside a model class. I use the  
validates\_presence\_of and validates\_uniqueness\_of methods inside the  
model class.

All this works well. I now want show a error message which contains  
the user submitted value.

For eg.

Username “penuel” is already in use.

Here “penuel” is the value entered by user in the form username text  
box, which is already used by some user.

currently I use the following method inside the model class

validates\_uniqueness\_of(:username, :message=\>“Username is already in  
use”)

How can embed the actual username submitted by user in the above error  
message.

Any pointers to this?

Thanks in advance.

Penuel
