Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
G

get_schwifty

> 编程语言
Open source

Render portions of your Rails view in a background job queue. ActiveJob + ActionCable.

186 stars0 likes4 views
WebsiteGitHub

About

Render portions of your Rails view in a background job queue. ActiveJob + ActionCable.

get_schwifty

Oh, yeah! You gotta get schwifty. You gotta get schwifty in here.

get_schwifty is a Rails plugin for rendering slow view partials in a background job and sending them to the client over ActionCable websockets.

Justification

Slow-to-render HTML elements can be expensive (hosting) and unavoidable (technical debt, slow libs, expensive db queries, etc). Rendering in-line in your web server consumes a connection which could be serving other clients. Sometimes it's better to just return a minimal page quickly, and let the data backfill as it's generated.

get_schwifty is all about quick responses by utilizing background jobs to do the rendering for your and delivering it to the client with ActionCable.

Caveats

  • There is no gurantee that the content will load. If your background job queue get's backed up, you'll be not showing content anytime soon.

Extracted from HireLoop

get_schwifty was extracted from HireLoop.io, a platform for a more human hiring experience.

Make hiring delightful by closing the loop between hiring managers and every applicant. Automate the trival tasks associated with screening job applicants, lowering the barrier for easy and clear communication.

Installation

Add this line to your application's Gemfile:

ruby
gem "get_schwifty"

And then execute:

bash
$ bundle

Or install it yourself as:

bash
$ gem install get_schwifty

Install the plugin

bash
$ rails generate get_schwifty:install

Follow the instructions printed.

Usage

Generate your first get_schwifty Cable

bash
$ rails generate get_schwifty:cable Calculator fibonacci

Cables are a place to put your data access logic. Think Controllers for each get_schwifty cable.

ruby
# app/cables/calculator_cable.rb

class CalculatorCable  is 

Lastly, we need to tell the app where to render this chunk of HTML. get_schwifty uses a similar routing syntax to Rails routes of cablecontrollername#action.

erb
# app/views/yourpage.html.erb
... Other HTML ...

  

    This will get displayed while the cable is waiting to get schwifty.
    Maybe markup for a loading animation?
  

... Other HTML ...

Load the page, and you should get the whole page back quickly, while the Fibonacci comes later.

Identifiers & Params

Random data isn't very useful. Unauthenticated data isn't very cool either. Usually in Rails data scoping belongs starts at a current_user method. get_schwifty will make any identefiers or params made available in the channel subscription within your cables. Let's take a look at an example.

Identifiers

Here we'll find the current user. This is copied form the Rails Guides.

ruby
# app/channels/connection.rb
module ApplicationCable
  class Connection 
  ... same as before ...

... Other HTML ...

These params will be available in your cable action.

ruby
# app/cables/calculator_cable.rb

class CalculatorCable < BaseCable
  def fibonacci
    n = SecureRandom.rand(params[:min_start]..40)
    ... same code as before ..
  end
end

License

The gem is available as open source under the terms of the MIT License.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Ruby

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言