Fix ActiveRecord::RecordNotSaved error