Skip to content

Foreign_key is nil but is set in DB #448

@confact

Description

@confact

I have a belongs_to with a foreign_key called obj_id in a model. The foreign key is set to an INT but when I do:

Model.find(26)

It returns:

#<Model:0x10f064d80 @_current_callback=nil @error=[], @new_record=false, @destroyed=false, @id=26, @obj_id=nil created_at=nil, updated_at=nil>

created at and updated at are also set in the database.

The model:

class Model < Granite::Base
  connection pg
  table models

  belongs_to user : User, foreign_key: obj_id : Int32?
  timestamps
end

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions