Realtime Collaboration Notes
Build a shared notes app in Ruby on Rails where signed-in team members edit the same notes at the same time and see each other's changes live through Action Cable (Rails' WebSocket framework), which uses Redis to deliver messages across server processes. Every save creates a revision, so you can see who changed what and restore an earlier version, and simultaneous edits are detected with version numbers so nobody silently overwrites someone else's work. Only members of a note's team can open or edit it, checked on every request and every WebSocket subscription. You'll learn Action Cable channels and authorization, Redis as a pub/sub backend, optimistic locking, revision history, and testing real-time Rails features.
- Estimate
- ~13h
- Steps
- 7
- Completed by
- 0
- Proposed by
- codeseed.app
Rails · Action Cable · Redis
Project roadmap
- 01
Design the app
~2hWrite DESIGN.md: teams, members, notes (title, body and lock_version), and revisions (note, author, body, created at and a summary of the change); how edits are sent (the client sends its full text or a patch with the version it started from), how conflicts are handled (a stale version is rejected and the client gets the latest text to merge), what is broadcast, and who may subscribe. Done when: DESIGN.md covers the data, sync and permissions.
- 02
Set up the app and permissions
~2hCreate a Rails app with authentication (Rails' built-in generator or Devise), teams and memberships, and notes belonging to a team. Enforce that only team members can see and change a team's notes, in controllers and in one policy class (such as with Pundit). Configure Action Cable to use Redis. Done when: users only see their teams' notes, and other notes return 404.
- 03
Broadcast changes with Action Cable
~2.5hCreate a NoteChannel that verifies the user (from the connection's identified user) belongs to the note's team before streaming for that note. When a note is saved, broadcast the new body, version and author. In the page, subscribe with the Action Cable JavaScript client and update the editor when others change the note, keeping the local cursor position. Done when: two browsers editing the same note see each other's changes within a second.
- 04
Detect conflicting edits
~2hSave edits with Rails' optimistic locking (lock_version), sent after the user pauses typing. When a save fails with StaleObjectError, send the latest text and version back, and in the browser merge simple non-overlapping changes automatically (for example with a diff library) or show both versions for the user to choose. Done when: two users typing in the same note at once never lose an edit without being told.
- 05
Keep revisions
~1.5hCreate a revision on each save (grouping saves by the same user within a minute into one revision to avoid thousands of tiny ones). Build a history page listing revisions with author and time, a diff between any revision and the current text, and a restore button that creates a new revision. Done when: history shows who changed what, and restoring works.
- 06
Show presence
~1hTrack who is currently viewing each note (in Redis, with expiry, updated by the channel's subscribed and unsubscribed callbacks and a periodic heartbeat), and show their names in the editor. Done when: opening a note in two browsers shows both users, and closing one removes it.
- 07
Test it
~2hWrite tests: channel tests with ActionCable::Channel::TestCase (members can subscribe, others are rejected, and saves broadcast), model tests for optimistic locking and revision grouping, request tests for permissions, and a system test with two browser sessions editing the same note. Done when: bin/rails test passes.
Ready to build this?
Get a GitHub repo and start building. Your AI reviewer checks each step as you go.
Tech stack