{"id":17500375,"url":"https://github.com/taphill/hotwired_todo","last_synced_at":"2026-05-16T11:01:53.181Z","repository":{"id":140754792,"uuid":"440927501","full_name":"taphill/hotwired_todo","owner":"taphill","description":"A simple Rails SPA","archived":false,"fork":false,"pushed_at":"2021-12-31T01:45:36.000Z","size":220,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-27T12:33:17.742Z","etag":null,"topics":["hotwire-stimulus","hotwire-turbo","rails7","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/taphill.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-22T16:57:46.000Z","updated_at":"2025-01-24T14:54:19.000Z","dependencies_parsed_at":"2024-08-27T18:32:17.135Z","dependency_job_id":null,"html_url":"https://github.com/taphill/hotwired_todo","commit_stats":{"total_commits":13,"total_committers":1,"mean_commits":13.0,"dds":0.0,"last_synced_commit":"1faa63946d604a11592c9c1ee9a0e7a48aa3e2b4"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/taphill/hotwired_todo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taphill%2Fhotwired_todo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taphill%2Fhotwired_todo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taphill%2Fhotwired_todo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taphill%2Fhotwired_todo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/taphill","download_url":"https://codeload.github.com/taphill/hotwired_todo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taphill%2Fhotwired_todo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33100319,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-16T04:41:52.686Z","status":"ssl_error","status_checked_at":"2026-05-16T04:41:52.009Z","response_time":115,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hotwire-stimulus","hotwire-turbo","rails7","ruby"],"created_at":"2024-10-19T18:09:00.659Z","updated_at":"2026-05-16T11:01:53.128Z","avatar_url":"https://github.com/taphill.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hotwired Todo\n\nA simple single-page application to experiment with the Hotwire tech stack which is now included by default in Rails 7.\n\n## Turbo-Frames\n\nTurbo-frames are the main mechanism used to create this Rails SPA. You'll notice that the URL never changes even when navigating to new content, just like one would expect with a React SPA.\n\nThis is done by using a turbo-frame that I referenced by the ID of `main-content`. All views and partials within the main section of the HTML document are wrapped by this turbo-frame.\n\n```html\n\u003cbody\u003e\n  \u003cheader\u003e\u003c/header\u003e\n  \u003cmain\u003e\n    \u003cturbo-frame id=\"main-content\"\u003e\n      \u003c!-- Content goes here --\u003e\n    \u003c/turbo-frame\u003e  \n  \u003c/main\u003e\n  \u003cfooter\u003e\u003c/footer\u003e\n\u003c/body\u003e\n```\n\n## Turbo-Streams\n\nTurbo-streams allow you to send fragments of a page change over WebSockets. You can see this in action when adding and deleting a todo item. Here's what the `users/todos_controller` looks like:\n\n```ruby\nmodule Users\n  class TodosController \u003c ApplicationController\n    def create\n      @todo = Todo.create(todo_params)\n    end\n\n    def destroy\n      todo = Todo.find(params[:id])\n      todo.destroy\n\n      render turbo_stream: turbo_stream.remove(todo)\n    end\n\n    private\n\n    def todo_params\n      params.permit(:user_id, :description)\n    end\n  end\nend\n```\n\nThe create action uses some rails magic to render the ![users/todos/create.turbo_stream.erb](https://github.com/taphill/hotwired_todo/blob/main/app/views/users/todos/create.turbo_stream.erb) file.\n\nFor the destroy action we explicitly tell it to render a turbo stream. Without specifying a partial it will look for one based on the file structure. So in this case it looks for ![users/todos/_todo.html.erb](https://github.com/taphill/hotwired_todo/blob/main/app/views/users/todos/_todo.html.erb). We also pass it the object so it knows which one to remove from the page based on the `dom_id` method.\n\n### Turbo Broadcasts\n\nTurbo stream broadcasts should be used when you need to broadcast a page update to all users at the same time. This will allow every user to see the changes as they happen. More information can be found here: https://github.com/hotwired/turbo-rails/blob/main/app/models/concerns/turbo/broadcastable.rb\n\nTo get broadcasts working in production on Heroku you also need to enable the redis gem in your rails application and then add redis to Heroku. If you're running on a hobby dev you can easily do that from the command line like this:\n\n```\n$ heroku addons:create heroku-redis:hobby-dev\n```\n\nYou can see an example of turbo-streams and turbo-broadcasts working in conjunction below:\n\n![](https://s10.gifyu.com/images/turbo_broadcast.gif)\n\n## Stimulus\n\nI found Stimulus really simple and convenient to use for adding sprinkles of javascript where needed. The largest Stimulus controller for this application is the [password_controller](app/javascript/controllers/password_controller.js) which renders different images to provide the user feedback as to when their password meets the requirements being enforced by the [User](app/models/user.rb) model. \n\n![](https://s10.gifyu.com/images/password_validation.gif)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftaphill%2Fhotwired_todo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftaphill%2Fhotwired_todo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftaphill%2Fhotwired_todo/lists"}