# In\_place\_editor and validations

**URL:** <https://www.ruby-forum.com/t/in-place-editor-and-validations/139669>\
**Category:** Rails\
**Created:** [June 5, 2008, 10:30pm UTC](https://www.ruby-forum.com/t/in-place-editor-and-validations/139669 "2008-06-05T22:30:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jawosis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/f04885/32.png) [@jawosis](https://www.ruby-forum.com/u/jawosis)\
**Post date:** [June 5, 2008, 10:30pm UTC](https://www.ruby-forum.com/t/in-place-editor-and-validations/139669/1 "2008-06-05T22:30:25Z")

</div>

I have a user model with “validate\_uniquness\_of :username”.

How to use build-in validations and in\_place\_editor?

I run Rails 2.1.

–  
Jochen

---

<div class="post-metadata">

**Author:** ![jawosis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/f04885/32.png) [@jawosis](https://www.ruby-forum.com/u/jawosis)\
**Post date:** [June 5, 2008, 10:42pm UTC](https://www.ruby-forum.com/t/in-place-editor-and-validations/139669/2 "2008-06-05T22:42:19Z")

</div>

Jochen K. wrote:

> I have a user model with “validate\_uniquness\_of :username”.
> 
> How to use build-in validations and in\_place\_editor?
> 
> I run Rails 2.1.
> 
> –  
> Jochen

I needed to do the same thing only with phone numbers and email address,  
so what I did is used a before\_save callback in my model to check on  
them to make sure they were formatted properly. I do, however, have the  
exact same code that you have - validate\_uniquness\_of :username. Is this  
not working for you or is it throwing some kind of error?

---

<div class="post-metadata">

**Author:** ![jawosis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/f04885/32.png) [@jawosis](https://www.ruby-forum.com/u/jawosis)\
**Post date:** [June 5, 2008, 11:11pm UTC](https://www.ruby-forum.com/t/in-place-editor-and-validations/139669/3 "2008-06-05T23:11:27Z")

</div>

Am 05.06.2008 um 22:42 schrieb Shandy N.:

> > Jochen
> 
> I needed to do the same thing only with phone numbers and email  
> address,  
> so what I did is used a before\_save callback in my model to check on  
> them to make sure they were formatted properly. I do, however, have  
> the  
> exact same code that you have - validate\_uniquness\_of :username. Is  
> this  
> not working for you or is it throwing some kind of error?

when I work in the console and try to create a user with an already  
existing  
username the error message is shown. but when I use in\_place\_editor I  
can  
change a username to let’s say “jochen” although there’s already such  
an entry  
in the db.

---

<div class="post-metadata">

**Author:** ![jawosis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/f04885/32.png) [@jawosis](https://www.ruby-forum.com/u/jawosis)\
**Post date:** [June 5, 2008, 11:43pm UTC](https://www.ruby-forum.com/t/in-place-editor-and-validations/139669/4 "2008-06-05T23:43:18Z")

</div>

The problem is how to tell the in place editor that validation  
failed. Take a look at  
[http://www.schumeyer.com/index.php/in-place-editor](http://www.schumeyer.com/index.php/in-place-editor)

I believe this will do what you want.

I have not had time to write much explanation. Feel free to email me  
with any questions.
