This doc was written by Claude after researching both the old app (catprint/) and
the new app (catprint_on_rails/) in June 2026. It is intended to be handed to a
developer who will implement this feature by working with Claude in the
catprint_on_rails repo. Claude will have full context if you paste this doc into
the conversation at the start of the session.
Here is a simple Rails Model and a Hyperstack Component. The Hyperstack Component uses Opal Ruby. Opal is a version of Ruby that runs on the Browser.
Hyperstack is a gem that wraps React with a Ruby DSL.
class Order < ApplicationRecord
...
scope :shipped, -> () { where(status: :shipped) }
...
endHere is a sample spec, there is a bug in the spec (not in the models.)
What is the bug?
describe Order do
describe "#submit" do
before do
@book = Book.new(:title => "RSpec Intro", :price => 20)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Hyperstack | |
| class InternalPolicy | |
| def self.log_times(model, times, messages_sent, accumlated_broadcast_time) | |
| times[:broadcast] = Time.now | |
| return if times[:broadcast]-times[:start] < 0.0100 # adjust this as needed | |
| ::Rails.logger.warn "*******************BROADCASTING MODEL CHANGES**************************" | |
| ::Rails.logger.warn "Model: #{model.inspect}" | |
| justification = 0 | |
| last_item_finished_at = times[:start] | |
| times.collect { |event, timestamp| [timestamp, event] } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Tweet < ApplicationRecord | |
| after_create_commit { broadcast_prepend_to "tweets" } | |
| after_update_commit { broadcast_replace_to "tweets" } | |
| after_destroy_commit { broadcast_remove_to "tweets" } | |
| validates :body, presence: true | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| json.extract! tweet, :id, :body, :likes_count, :retweets_count, :created_at, :updated_at | |
| json.url tweet_url(tweet, format: :json) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class LikesController < ApplicationController | |
| before_action :set_tweet | |
| def create | |
| @tweet.increment! :likes_count | |
| redirect_to @tweet | |
| end | |
| private |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <%= turbo_frame_tag dom_id(tweet) do %> | |
| <div class="card card-body"> | |
| <div><%= tweet.body %></div> | |
| <div class="mt-2"> | |
| <%= button_to "Likes (#{tweet.likes_count})", tweet_like_path(tweet), method: :post %> | |
| <%= button_to "Retweets (#{tweet.retweets_count})", tweet_retweet_path(tweet), method: :post %> | |
| <%= link_to "Edit", edit_tweet_path(tweet) %> | |
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ShowTweet < HyperComponent | |
| param :tweet | |
| render(DIV, class: "card card-body") do | |
| DIV { tweet.body } unless @editing | |
| DIV(class: "mt-2") do | |
| BUTTON { "Likes (#{tweet.likes_count})" }.on(:click) { tweet.increment!(:likes_count) } | |
| BUTTON { "Retweets (#{tweet.retweets_count})" }.on(:click) { tweet.increment!(:retweets_count) } | |
| if @editing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # app/hyperstack/libs/throttle.rb | |
| class Throttle | |
| # call the provided block (using the run method) no faster than the | |
| # specified update frequency. | |
| def initialize(update_frequency = 0.5, &block) | |
| @update_frequency = update_frequency | |
| @block = block | |
| @last_start_time = Time.now - update_frequency |
NewerOlder