【发布时间】:2020-04-06 13:18:18
【问题描述】:
我已将我的项目升级到 Rails6 (v6.0.1),现在在我的模型中使用 Action Text。但是,我找不到更改我的 Ransack 以便能够从内容中搜索文本的方法,据我所知,在 Action Text 迁移之后,它现在存储在表 action_text_rich_texts 的属性 body 中。有人有好的建议吗?
错误信息:
undefined method `content_body_cont' for Ransack::Search<class: Topic, base: Grouping <combinator: and>>:Ransack::Search
以下是我的代码摘录。
型号:
class Topic < ApplicationRecord
has_rich_text :content
控制器:
class TopicsController < ApplicationController
def index
@search = Topic.ransack(params[:q])
@topics = @search.result
end
end
查看:
<%= search_form_for(@search, url: topics_path, html: {method: :get, role: 'form'}) do |f| %>
<%= f.text_field :content_body_cont %>
架构文件:
create_table "action_text_rich_texts", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC", force: :cascade do |t|
t.string "name", null: false
t.text "body", size: :long
t.string "record_type", null: false
t.bigint "record_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["record_type", "record_id", "name"], name: "index_action_text_rich_texts_uniqueness", unique: true
end
【问题讨论】:
标签: ruby-on-rails ransack ruby-on-rails-6 actiontext