Why is created_at
null and how would I resolve this?
↳ app/controllers/projects_controller.rb:28:in `create'
Tag Upsert (5.6ms) INSERT INTO "tags" ("category","name") VALUES ('topic', 'career') ON CONFLICT ("id") DO UPDATE SET "type"=excluded."type","name"=excluded."name" RETURNING "id"
↳ app/controllers/projects_controller.rb:32:in `block in create'
Completed 500 Internal Server Error in 62ms (ActiveRecord: 31.0ms | Allocations: 22999)
ActiveRecord::NotNullViolation (PG::NotNullViolation: ERROR: null value in column "created_at" violates not-null constraint
DETAIL: Failing row contains (5, topic, career, null, null).
):
app/controllers/projects_controller.rb:32:in `block in create'
app/controllers/projects_controller.rb:31:in `each'
app/controllers/projects_controller.rb:31:in `create'
# projects_controller.rb
def create
@project = Project.create(project_params)
if @project.valid?
# tags
params[:tags].each do |tag|
@tag = Tag.upsert({ category: 'topic', name: tag })
ProjectTag.create(tag: @tag, project: @project)
end
respond_to do |format|
format.json { render json: { "message": "success!", status: :ok } }
end
end
end