Reputation: 1006
I am using Rails 3.1. I have a database column t.datetime "end_at". If I enter a date at the time of object creation, then I can change the value (update) later. But If I leave it blank (NULL), I found that I cannot update it. I verified that the name and new value of the field are in the params. Why?
def update
begin
model = MyModel.find(params[:id])
model.update_attributes!(params[:my_model])
rescue ActiveRecord::RecordNotFound => e
#something
end
end
Upvotes: 0
Views: 779
Reputation: 7856
You need to make sure two things are true:
params[:end_at]
must contain a nil or a DateTime. Normally params do not come in as datetime.Also investigate multiparameter attributes.
Upvotes: 1