I've upgraded my project to Rails6 (v6.0.1) and now using Action Text in my model. However I cannot find a way to change my Ransack to be able to search text from the content, which I understand that after Action Text migration it is now stored within attribute body
of table action_text_rich_texts
. Would anyone have a good suggestion?
Error message:
undefined method `content_body_cont' for Ransack::Search<class: Topic, base: Grouping <combinator: and>>:Ransack::Search
Below is the extract of my code.
Model:
class Topic < ApplicationRecord
has_rich_text :content
Controller:
class TopicsController < ApplicationController
def index
@search = Topic.ransack(params[:q])
@topics = @search.result
end
end
View:
<%= search_form_for(@search, url: topics_path, html: {method: :get, role: 'form'}) do |f| %>
<%= f.text_field :content_body_cont %>
Schema file:
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