# Validates problem

**URL:** <https://www.ruby-forum.com/t/validates-problem/161771>\
**Category:** Rails\
**Created:** [March 2, 2009, 10:29am UTC](https://www.ruby-forum.com/t/validates-problem/161771 "2009-03-02T10:29:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![giga](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b9bd4f/32.png) [@giga](https://www.ruby-forum.com/u/giga)\
**Post date:** [March 2, 2009, 10:29am UTC](https://www.ruby-forum.com/t/validates-problem/161771/1 "2009-03-02T10:29:12Z")

</div>

Validation:  
validates\_presence\_of :name  
validates\_length\_of :name, :maximum =\> 150  
validates\_inclusion\_of :category, :in =\> %w( X Y XY )  
validates\_length\_of :gender, :maximum =\> 3  
validates\_length\_of :tag, :within =\> 1…10

Data sended

data: !map:HashWithIndifferentAccess  
name: Bond  
category: X  
tag: standard

Errors:

Category is not included in the list  
Tag is too short (minimum is 1 characters)  
Gender is too long (maximum is 3 characters)

What wrong?

Category is in list  
Tag can’t be too short, it 8 char  
And gender can’t be too long, because there is no gender value at all.

---

<div class="post-metadata">

**Author:** ![giga](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b9bd4f/32.png) [@giga](https://www.ruby-forum.com/u/giga)\
**Post date:** [March 2, 2009, 10:37am UTC](https://www.ruby-forum.com/t/validates-problem/161771/2 "2009-03-02T10:37:36Z")

</div>

can you set a debugger in your Controller/Model to see what is  
actually received?

---

<div class="post-metadata">

**Author:** ![giga](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b9bd4f/32.png) [@giga](https://www.ruby-forum.com/u/giga)\
**Post date:** [March 2, 2009, 10:37am UTC](https://www.ruby-forum.com/t/validates-problem/161771/3 "2009-03-02T10:37:51Z")

</div>

Try with following

validates\_inclusion\_of :category, :in =\> %w( X, Y, XY )  
validates\_length\_of :gender, :maximum =\> 3, :allow\_nil =\> true  
validates\_length\_of :tag, :in =\> 1…10

---

<div class="post-metadata">

**Author:** ![giga](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b9bd4f/32.png) [@giga](https://www.ruby-forum.com/u/giga)\
**Post date:** [March 2, 2009, 5:09pm UTC](https://www.ruby-forum.com/t/validates-problem/161771/4 "2009-03-02T17:09:00Z")

</div>

MaD wrote:

> can you set a debugger in your Controller/Model to see what is  
> actually received?

How can I se a debbuger?

> validates\_inclusion\_of :category, :in =\> %w( X, Y, XY )  
> validates\_length\_of :gender, :maximum =\> 3, :allow\_nil =\> true  
> validates\_length\_of :tag, :in =\> 1…10

gender works now, but tag and category nope.

---

<div class="post-metadata">

**Author:** ![giga](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b9bd4f/32.png) [@giga](https://www.ruby-forum.com/u/giga)\
**Post date:** [March 3, 2009, 5:28am UTC](https://www.ruby-forum.com/t/validates-problem/161771/5 "2009-03-03T05:28:28Z")

</div>

> How can I se a debbuger?

You need to install ruby-debug gem first Check if it already installed  
gem list

write debugger at the place where u want debugging and now start  
your server like  
./script/server --debugger then you will get debug prompt Type h for  
help to get available commands  
example : to print any value say @var  
p @var

---

<div class="post-metadata">

**Author:** ![giga](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b9bd4f/32.png) [@giga](https://www.ruby-forum.com/u/giga)\
**Post date:** [March 3, 2009, 6:43am UTC](https://www.ruby-forum.com/t/validates-problem/161771/6 "2009-03-03T06:43:55Z")

</div>

Fresh M. wrote:

> MaD wrote:
> 
> > can you set a debugger in your Controller/Model to see what is  
> > actually received?
> 
> How can I se a debbuger?
> 
> > validates\_inclusion\_of :category, :in =\> %w( X, Y, XY )  
> > validates\_length\_of :gender, :maximum =\> 3, :allow\_nil =\> true  
> > validates\_length\_of :tag, :in =\> 1…10
> 
> gender works now, but tag and category nope.

For tag also you give  
validates\_length\_of :tag, :maximum=\>10 like that and try… you can give  
minimum also in this…
