我有一个用户模型,它的描述是富文本
has_rich_text :description
字符串
我想运行查询来检查哪些用户有描述?
这样的事情
User.where.not(description: nil)
型
我的问题是:
- 是否可以检查操作文本是否存在?
- 可以在用户模型has_description(boolean)上创建迁移,并在
before_save
上更新,然后运行查询where has_description true
我有一个用户模型,它的描述是富文本
has_rich_text :description
字符串
我想运行查询来检查哪些用户有描述?
这样的事情
User.where.not(description: nil)
型
我的问题是:
before_save
上更新,然后运行查询where has_description true
1条答案
按热度按时间idv4meu81#
Rails会自动添加一个
has_one
关联rich_text_#{name}
:您可以使用它来联接(或预加载)关联并过滤出内部Action Text表:
字符串