booleans in rails with sqlite

后端 未结 2 2027
醉话见心
醉话见心 2021-02-08 22:22

I am a bit of a noob still with rails, but I am running across something that seems a bit odd. I added a boolean field to a model in the database thusly

t.column         


        
相关标签:
2条回答
  • 2021-02-08 23:00

    The problem may be with the database migration. I don't think that :bool is the right data type name to use. Try :boolean instead, e.g.

    t.column :admin, :boolean, :default => false, :null => false
    
    0 讨论(0)
  • 2021-02-08 23:10

    Use this instead:

    t.column :admin, :boolean, :default => false, :null => false
    

    Read why here.

    0 讨论(0)
提交回复
热议问题