{"id":32932924,"url":"https://github.com/hiroaki/unified-flash-messages","last_synced_at":"2026-02-01T06:03:45.755Z","repository":{"id":314274653,"uuid":"1054798071","full_name":"hiroaki/unified-flash-messages","owner":"hiroaki","description":"Unified flash message demo: server and client messages with shared templates and logic","archived":false,"fork":false,"pushed_at":"2026-01-15T09:32:05.000Z","size":262,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"develop","last_synced_at":"2026-01-15T11:23:36.527Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"0bsd","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hiroaki.png","metadata":{"files":{"readme":"README.ja.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-11T10:47:45.000Z","updated_at":"2026-01-15T04:19:51.000Z","dependencies_parsed_at":"2026-01-15T07:06:31.789Z","dependency_job_id":null,"html_url":"https://github.com/hiroaki/unified-flash-messages","commit_stats":null,"previous_names":["hiroaki/unified-flash-messages"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/hiroaki/unified-flash-messages","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hiroaki%2Funified-flash-messages","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hiroaki%2Funified-flash-messages/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hiroaki%2Funified-flash-messages/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hiroaki%2Funified-flash-messages/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hiroaki","download_url":"https://codeload.github.com/hiroaki/unified-flash-messages/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hiroaki%2Funified-flash-messages/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28970194,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-01T05:48:53.985Z","status":"ssl_error","status_checked_at":"2026-02-01T05:47:55.855Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":[],"created_at":"2025-11-11T18:46:40.783Z","updated_at":"2026-02-01T06:03:45.749Z","avatar_url":"https://github.com/hiroaki.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 共通フラッシュ・メッセージ実装例\n\nこのリポジトリは、サーバーサイドとクライアントサイドの両方から利用できる統一的な Flash メッセージ描画の仕組みを Rails アプリに提供するための Rails 用 gem - `flash-unified` を実装したデモ・アプリケーションです。\n\nバージョン v0.2.0 までは Flash の扱いについてのアイデアを実装するために進めてきましたが、その後、それを再利用できる形にした gem `flash-unified` を作成したため、その gem を逆輸入して利用するように改造しました。\n\nコンセプトや実装の背景は、その gem `flash-unified` のリポジトリのほうで説明していますので、そちらを参照してください。\n\n[https://github.com/hiroaki/flash-unified](https://github.com/hiroaki/flash-unified)\n\n## 環境構築手順\n\nこの Rails アプリケーションを試す場合は、次のように環境構築してください。\n\n### Docker Compose を使う場合\n\n`compose.yml` を用意していますので、内容を確認のうえビルドしてください。\n\n```bash\n$ docker compose up --build\n```\n\nコンテナが立ち上がったら、コンテナ内から、後述の \"初回セットアップ\" を実行してください。\n\nなおコンテナの起動において、 Rails サーバは自動では起動しません。サーバの起動、およびその他 Rails コマンドの類はすべて、コンテナ内から実行します。コンテナの外部からもアクセスできるように、アドレスは `0.0.0.0` をバインドしてください：\n\n```bash\n$ docker compose exec -e BINDING=0.0.0.0 web bin/rails s\n```\n\nこの compose で起動したコンテナは、バインド・マウントの設定で、ホスト上のカレント・ディレクトリをコンテナにマウントしています。ホスト上の修正はコンテナ内の Rails に即座に反映されます。\n\n### Docker を使わない場合\n\n単純な Rails アプリですので特別なことはありません。データベースは SQLite3 を使用していますので、その初期化を行い、Rails サーバーを起動するだけです。\n\n### 初回セットアップ\n\n`bundle install` を実行し、データベースをセットアップしてください：\n\n```bash\n$ docker compose exec web bundle install\n$ docker compose exec web bin/rails db:prepare\n```\n\nまたは：\n\n```bash\n$ docker compose exec web bin/setup --skip-server\n```\n\n### Tailwind CSS\n\nCSS には Tailwind を使用しているため、はじめてセットアップした時や、その後 CSS を変更した際はビルドが必要です。\n```bash\n$ docker compose exec web bin/rails tailwindcss:build\n```\n\n開発中は、自動で変更を検知してビルドするプロセスを実行しておくとよいでしょう。\n```bash\n$ docker compose exec web bin/rails tailwindcss:watch\n```\n\n`bin/dev` を使用すれば、 Rails の起動と Tailwind の自動ビルドのプロセスを同時に起動できます：\n```bash\n$ docker compose exec -e BINDING=0.0.0.0 web bin/dev\n```\n\n## 動作確認例\n\nこのアプリケーションは、次のように Memo モデルを scaffold で作成しものがベースになっています：\n```bash\n$ rails generate scaffold Memo title:string description:text\n```\n\nサーバサイドではレスポンスの際に Flash メッセージがセットされるよう実装しています。これは通常の Flash メッセージの使い方になります。\n\n| シナリオ | 手順 | 期待される Flash のタイプとメッセージ |\n|---|---|---|\n| 新規作成成功 | タイトル/説明を入力し保存 | notice: \"Created successfully.\" |\n| バリデーション失敗 | 空で送信 | alert: \"Could not create.\" |\n| 編集成功 | 既存メモを編集保存 | notice: \"Updated successfully.\" |\n| 削除成功 | Destroy ボタン | notice: \"Destroyed successfully.\" |\n\n一覧（ index アクション）画面には、絞り込みのフォームがあります。これは Turbo Frame で実装している部分で、絞り込み結果はページ全体ではなく、検索結果のリストを表示するフレーム内のみを更新します。\n\n| シナリオ | 手順 | 期待される Flash のタイプとメッセージ |\n|---|---|---|\n| offset 範囲外 | 全件数より大きな値を offset に入力して Apply | warning: \"No memos found for the specified offset; it may be out of range.\" |\n| limit 制限超過| 内部の制限値 10 を超えた値を limit に入力して Apply | alert: \"limit must be \u003c= 10\" |\n\nクライアントサイドから表示するメッセージも実装してあり、それぞれ次のような手順で確認できます：\n\n| シナリオ | 手順 | 期待される Flash のタイプとメッセージ |\n|---|---|---|\n| 禁止文字列 | 文字列 \"test\" を送信 | alert: \"Submission blocked: contains forbidden word.\" |\n\nまたネットワーク切断時などに発生するイベント `turbo:fetch-request-error` を検知した場合に、汎用のエラーメッセージを生成して表示するようにしています。これを試すためのネットワーク遮断のシミュレーションは、 Chrome であればブラウザのコンソールの \"ネットワーク\" タブから \"オフライン\" を選択することで再現できます。\n\n\n## ライセンス\n\n本プロジェクトは **0BSD (Zero-Clause BSD)** ライセンスです。詳細は `LICENSE` を参照してください。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhiroaki%2Funified-flash-messages","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhiroaki%2Funified-flash-messages","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhiroaki%2Funified-flash-messages/lists"}