Below are concise answers to common questions when working with the Folio Rails Engine. Every answer is verified against the current source code or official generators.
Run the generator:
rails generate folio:atom MyBlockThis creates the model, component, tests, and i18n entries. Edit the generated files to add fields and rendering logic.
- add class to one of
console_sidebar_prepended_links,console_sidebar_before_menu_links,console_sidebar_before_site_linksin yourFolio::Sitesubclass - add class to
config/initializers/folio.rb– optionconfig.folio_console_sidebar_link_class_names
Set config.folio_console_locale in config/initializers/folio.rb (default :cs).
Enable Folio cross-domain functionality:
config.folio_crossdomain_devise = trueYes. Folio components only use direct S3 uploads.
Inherit from the provided base classes (Folio::CapybaraTest, Folio::BaseControllerTest, etc.) which set up a site automatically. Alternatively call Folio::Current.reset and assign Folio::Current.site manually in test setup.
Yes:
config.folio_use_og_image = falseSet delivery method in config/environments/production.rb, and configure credentials as usual. Folio mailers inherit from Folio::ApplicationMailer, so any ActionMailer setting applies.
Legacy Cells are supported but new development should use ViewComponent. Use the folio:component generator instead of folio:cell.
Override Folio::Ability in app/overrides/ and add rules using CanCan syntax. See the Abilities section in Admin chapter.
If your HTML content is being stripped, it is likely caused by the default sanitization behavior. By default, attributes not explicitly defined in the :attributes hash of the folio_html_sanitization_config method are sanitized using Loofah, which removes all HTML tags. To preserve specific HTML content, ensure that the attribute is included in the :attributes hash with the appropriate sanitization configuration, such as :rich_text or a custom proc.
To disable sanitization for a specific model, override the folio_html_sanitization_config method in the model and set { enabled: false } in the configuration. For example:
def folio_html_sanitization_config
{ enabled: false }
endThis will bypass all sanitization for the model.
Yes, you can allow specific HTML tags and attributes by using the :rich_text configuration. This uses Rails::HTML5::SafeListSanitizer, which keeps safe HTML tags and attributes.
You can use :unsafe_html to completely disable sanitization for a specific attribute.
If you need more granular control, you can define a custom proc to handle sanitization logic for specific attributes.
See Sanitization for more information.
Attributes not explicitly listed in the :attributes hash of the folio_html_sanitization_config method are sanitized using Loofah, which removes all HTML tags. This ensures that any unconfigured attributes are stripped of potentially unsafe HTML content by default.
Have a question not listed here? Create an issue on GitHub or check the Troubleshooting chapter.