Sachin Prasad
Sachin Prasad

Reputation: 5411

Inserting a column value with null in ruby on rails

I want to customize the value inserted in the column in the controller and i want to insert a null value in it. In this way :

@users.to = null

Upvotes: 0

Views: 2118

Answers (1)

Alex Peattie
Alex Peattie

Reputation: 27657

I believe you want:

@user.to = nil

You may have to run a migration to ensure the column allows NULL values:

change_column :users, :to, :string, :null => true

Upvotes: 3

Related Questions