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

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?

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.

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

Bill

devaulw wrote:

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

Bill

Ah! Bill wins. Thanks.