RuntimeError: Ransack needs ActionText::RichText attributes explicitly allowlisted
7 months ago
# RuntimeError: # Ransack needs ActionText::RichText attributes explicitly allowlisted as # searchable. Define a `ransackable_attributes` class method in your `ActionText::RichText` # model, watching out for items you DON'T want searchable (for # example, `encrypted_password`, `password_reset_token`, `owner` or # other sensitive information). You can use the following as a base: # # ```ruby # class ActionText::RichText < ApplicationRecord # # # ... # # def self.ransackable_attributes(auth_object = nil) # ["body", "created_at", "id", "locale", "name", "record_id", "record_type", "updated_at"] # end # # # ... # # end Solution: # config/initializers/action_text.rb ActiveSupport.on_load(:action_text_rich_text) do class ActionText::RichText < ActionText::Record def self.ransackable_attributes(auth_object = nil) authorizable_ransackable_attributes end end end
Ransack