为什么在rails中使用blob数据类型时数据库迁移失败?

时间:2022-05-06 05:33:08

I'm trying to create a simple application with ruby in rails. I've created this scaffold:

我正在尝试用rails中的ruby创建一个简单的应用程序。我创建了这个脚手架:

rails generate scaffold Pic title:string content:blob description:text

and when I try to migrate db with rake db:migrate I'm getting this error:

当我尝试使用rake db:migrate迁移db时,我收到此错误:

rake aborted!
An error has occurred, this and all later migrations canceled:

undefined method `blob' for #<ActiveRecord::ConnectionAdapters::TableDefinition:0xb74f8ec4>

When I write say text instead of blob it works normally. So what's the problem with blob ?

当我写文字而不是blob时,它正常工作。那么blob的问题是什么?

2 个解决方案

#1


13  

The keyword is binary, not blob.

关键字是二进制,而不是blob。

rails generate scaffold Pic title:string content:binary description:text

#2


2  

There is no keyword blob in rails, you need binary.

rails中没有关键字blob,你需要二进制文件。

rails generate scaffold Pic title:string content:binary description:text

#1


13  

The keyword is binary, not blob.

关键字是二进制,而不是blob。

rails generate scaffold Pic title:string content:binary description:text

#2


2  

There is no keyword blob in rails, you need binary.

rails中没有关键字blob,你需要二进制文件。

rails generate scaffold Pic title:string content:binary description:text