Install
The Rails integration ships as the poli_page-rails gem on RubyGems. It wraps the Ruby SDK, poli-page, in a Rails engine, and Bundler installs the SDK with it.
Requirements
Section titled “Requirements”- Ruby 3.2 or newer
- Rails 7.0, 7.1, 7.2 or 8.0 (
railties,actionpackandactivesupport>= 7.0, < 9) - The
poli-pageSDK~> 0.13.0, the same minor as this gem - A Poli Page API key, from poli.page/dashboard
CI tests Ruby 3.2, 3.3 and 3.4 against Rails 7.0, 7.1, 7.2 and 8.0.
Install the gem
Section titled “Install the gem”# Gemfilegem "poli_page-rails", "~> 0.13.0"bundle installSet your API key
Section titled “Set your API key”Put the key in the environment your app reads:
POLI_PAGE_API_KEY=pp_sandbox_xxxA key is pp_{environment}_{32 lowercase hex}, where {environment} is the environment it belongs to. The key alone selects the environment, so a render never names a version:
| Environment | Key | Watermark | Counted |
| --- | --- | --- | --- |
| sandbox (every org) | pp_sandbox_… | yes | no |
| live (every org, deletable on Pro+) | pp_live_… | no | yes |
| created on Pro+ (e.g. staging) | pp_staging_… | no | yes |
“Counted” means the render counts toward the organization’s monthly PDF quota.
Run the generator
Section titled “Run the generator”The gem is an engine: a Railtie installs the configuration object, so there is nothing to register. The generator writes a commented initializer for you to edit:
bin/rails generate poli_page:installIt creates config/initializers/poli_page.rb, which reads POLI_PAGE_API_KEY with ENV.fetch. Restart the app after you set the key. To check the setup end to end, run the example app in the repo’s example-app/.
Example
Section titled “Example”Rails.application.config.poli_page.tap do |c| c.api_key = ENV.fetch("POLI_PAGE_API_KEY")end