unpoly-rails

Ruby on Rails integration for Unpoly. Use when working with the unpoly-rails gem or building Unpoly-powered Rails apps. Covers server-side helpers (up?, up.target, up.layer.accept, up.layer.dismiss, up.layer.open, up.validate?, up.cache.expire, up.context, up.emit, up.safe_callback, fresh_when, render_nothing), Rails view helpers (link_to, form_with, button_to with Unpoly attributes), flash messages with [up-hungry], Turbo coexistence (disabling Turbo Drive in Rails 7+), CSP setup with csp_meta_tag, and global follow-all config.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "unpoly-rails" with this command: npx skills add thomasklemm/unpoly-skills/thomasklemm-unpoly-skills-unpoly-rails

Unpoly Rails

The unpoly-rails gem integrates Unpoly's server protocol into Rails, exposing helper methods in controllers, views, and helpers.

Gem: unpoly-rails — tracks Unpoly 3.x

Installation

# Gemfile
gem 'unpoly-rails'

Frontend assets via Asset Pipeline

// application.js
//= require unpoly
/* application.css
 *= require unpoly
 */

Frontend assets via npm (esbuild, Webpacker, etc.)

import 'unpoly/unpoly.js'
import 'unpoly/unpoly.css'

Quick reference

HelperPurpose
up?Is this an Unpoly fragment request?
up.targetCSS selector being updated (success)
up.target = 'body'Override the render target
up.target?('.sel')Is this selector targeted?
up.fail_targetCSS selector targeted for failed responses
up.fail_target?('.sel')Is this selector targeted on failure?
up.any_target?('.sel')Is selector targeted for success or failure?
up.validate?Is this a form validation request?
up.validate_namesArray of field names that triggered validation
up.validate_nameFirst validating field name (or nil)
up.validate_name?('email')Is this specific field being validated?
up.layer.modeLayer mode: "root", "modal", "drawer", etc.
up.layer.overlay?Is the targeted layer an overlay?
up.layer.root?Is the targeted layer the root layer?
up.layer.accept(value)Accept the current overlay (raises CannotClose on root layer)
up.layer.dismiss(value)Dismiss the current overlay (raises CannotClose on root layer)
up.layer.open(...)Request frontend to open a new overlay
up.layer.emit(type, props)Emit event on the targeted layer
up.layer.contextLayer context hash
up.contextAlias for up.layer.context
up.fail_layer.modeMode of layer targeted for failed responses
up.origin_layer.modeMode of the layer that caused the request
up.modeShortcut for up.layer.mode
up.fail_modeShortcut for up.fail_layer.mode
up.origin_modeShortcut for up.origin_layer.mode
up.emit(type, props)Emit event on document after update
up.cache.expireExpire the client-side cache (triggers revalidation)
up.cache.expire('/path/*')Expire matching URL pattern
up.cache.evictEvict entries from the client-side cache
up.title = 'Title'Set document title from server
up.versionUnpoly JS version string (from X-Up-Version header)
up.safe_callback("js()")CSP-safe inline callback with nonce
head(:no_content)Render empty 204 response (replaces deprecated up.render_nothing)
up.no_vary { }Read Unpoly headers without setting Vary

Reference files

Load when the user's question covers that topic:

  • server-helpers.md — Full API reference: request inspection, response control, layer API, validation, events, cache control, context, CSP callbacks, failed forms, Vary headers, conditional GETs, common Rails patterns
  • rails-integration.md — View helper syntax (link_to, form_with, button_to, field helpers), Turbo coexistence (disabling Turbo Drive in Rails 7+), CSP setup with csp_meta_tag, global follow-all config
  • patterns.md — End-to-end Rails patterns: drawer overlay helper, event-driven subinteractions (up-accept-event/up-dismiss-event), create related record inline + validate parent form, authorization overlay vs root layer
  • gotchas.md — Real-world pitfalls: [up-accept-location] matching the opening URL, [up-hungry] flash wiped unexpectedly, system test submit race with [up-validate]

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

unpoly

No summary provided by upstream source.

Repository SourceNeeds Review
General

image-gen

Generate AI images from text prompts. Triggers on: "生成图片", "画一张", "AI图", "generate image", "配图", "create picture", "draw", "visualize", "generate an image".

Archived SourceRecently Updated
General

explainer

Create explainer videos with narration and AI-generated visuals. Triggers on: "解说视频", "explainer video", "explain this as a video", "tutorial video", "introduce X (video)", "解释一下XX(视频形式)".

Archived SourceRecently Updated
General

asr

Transcribe audio files to text using local speech recognition. Triggers on: "转录", "transcribe", "语音转文字", "ASR", "识别音频", "把这段音频转成文字".

Archived SourceRecently Updated