# New column "can't be blank," but it's not

**URL:** <https://www.ruby-forum.com/t/new-column-cant-be-blank-but-its-not/78734>\
**Category:** Rails\
**Created:** [December 8, 2006, 4:05am UTC](https://www.ruby-forum.com/t/new-column-cant-be-blank-but-its-not/78734 "2006-12-08T04:05:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![justinskolnick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b5a626/32.png) [@justinskolnick](https://www.ruby-forum.com/u/justinskolnick)\
**Post date:** [December 8, 2006, 4:05am UTC](https://www.ruby-forum.com/t/new-column-cant-be-blank-but-its-not/78734/1 "2006-12-08T04:05:52Z")

</div>

I’ve added a new column, “offset”, to my “users” table, set the  
corresponding model to validate\_presence\_of offset, and added the field  
to my “add user” view:

\<%= select(“user”, “offset”, %w{ -6 }) %\>

(Simplified here to a single option)

From the console:  
Parameters: {“user”=\>{“name”=\>“tommy”, “password”=\>“gun”,  
“offset”=\>"-6"},  
“action”=\>“login”, “controller”=\>“users”}

So there’s an option selected and the offset parameter makes POST. Why  
then doesn’t this pass validation? Rails tells me this:

“Offset can’t be blank”

WTF?

---

<div class="post-metadata">

**Author:** ![justinskolnick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b5a626/32.png) [@justinskolnick](https://www.ruby-forum.com/u/justinskolnick)\
**Post date:** [December 8, 2006, 6:51pm UTC](https://www.ruby-forum.com/t/new-column-cant-be-blank-but-its-not/78734/2 "2006-12-08T18:51:54Z")

</div>

Justin S. wrote:

> I’ve added a new column, “offset”, to my “users” table, set the  
> corresponding model to validate\_presence\_of offset, and added the field  
> to my “add user” view:
> 
> \<%= select(“user”, “offset”, %w{ -6 }) %\>
> 
> (Simplified here to a single option)
> 
> From the console:  
> Parameters: {“user”=\>{“name”=\>“tommy”, “password”=\>“gun”,  
> “offset”=\>"-6"},  
> “action”=\>“login”, “controller”=\>“users”}
> 
> So there’s an option selected and the offset parameter makes POST. Why  
> then doesn’t this pass validation? Rails tells me this:
> 
> “Offset can’t be blank”
> 
> WTF?

There is no controller code there. The parameters are being created  
correctly, but what are you doing with them to create your object? That  
is most likely where your problem lies.

---

<div class="post-metadata">

**Author:** ![justinskolnick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b5a626/32.png) [@justinskolnick](https://www.ruby-forum.com/u/justinskolnick)\
**Post date:** [December 8, 2006, 8:31pm UTC](https://www.ruby-forum.com/t/new-column-cant-be-blank-but-its-not/78734/3 "2006-12-08T20:31:58Z")

</div>

There’s also no model code. Is the attribute protected?

Bill

---

<div class="post-metadata">

**Author:** ![justinskolnick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b5a626/32.png) [@justinskolnick](https://www.ruby-forum.com/u/justinskolnick)\
**Post date:** [December 9, 2006, 6:21pm UTC](https://www.ruby-forum.com/t/new-column-cant-be-blank-but-its-not/78734/4 "2006-12-09T18:21:33Z")

</div>

devaulw wrote:

> There’s also no model code. Is the attribute protected?
> 
> Bill

Ah! Bill wins. Thanks.
