Bilingual README / 雙語說明: English · 中文
Rails app for budgeting and actual expenditure tracking. The UI uses Phlex views, RubyUI (Tailwind / shadcn-style) components, Propshaft for assets, and Importmap for JavaScript.
以 Rails 打造的預算與實際支出追蹤應用;介面使用 Phlex 視圖、RubyUI(Tailwind / shadcn 風格)元件、Propshaft 管理靜態資源,並以 Importmap 載入 JavaScript。
- Ruby 3.4.x (see
.ruby-version; project usesruby-3.4.8) - Bundler
- Node is optional for this repo; Tailwind is built via the
tailwindcss-railsgem (nonpm runrequired for CSS) - SQLite for local development (databases under
storage/) - The PostgreSQL gem is included for deployments that set
DATABASE_URL; adjustconfig/database.ymlif you use Postgres locally
bin/setupThis installs gems, runs bin/rails tailwindcss:build, prepares the database, then starts bin/dev (Rails + Tailwind watch).
Manual equivalent:
bundle install
bin/rails tailwindcss:build
bin/rails db:prepare
bin/devdevOpen http://localhost:3000.
bin/rails tailwindcss:build— generatesapp/assets/builds/tailwind.css. Without it, pages load but have almost no styling.- Prefer
bin/devoverbin/rails serveralone sotailwindcss:watchrecompiles CSS when you editapp/assets/tailwind/application.css.
| Piece | Role |
|---|---|
| Rails 8.1 | Web framework |
| Propshaft | Serves fingerprinted assets from app/assets |
| tailwindcss-rails | Compiles app/assets/tailwind/application.css → app/assets/builds/tailwind.css |
Phlex (phlex-rails) |
Ruby HTML/views under app/views/ |
| RubyUI | Component library under app/components/ruby_ui/ |
| Hotwire | Turbo + Stimulus via importmap |
The layout uses stylesheet_link_tag :app, which links every app/assets/**/*.css that exists (including the Tailwind build under app/assets/builds/). That avoids Propshaft::MissingAssetError if tailwind.css has not been built yet (you only miss styles until you run tailwindcss:build).
Do not rely on stylesheet_link_tag "tailwind" unless you are sure app/assets/builds/tailwind.css exists in every environment (CI, Docker, new clones).
Theme tokens (colors, radius, sidebar variables) live in app/assets/tailwind/application.css.
| Path | Description |
|---|---|
/ |
Dashboard — actual expenditure |
/revenue_budgets |
Revenue budgets (placeholder) |
/expenditure_budgets |
Expenditure budgets (placeholder) |
/settings |
Settings (placeholder) |
- Shell:
app/views/layouts/application.html.erbwraps content inRubyUI::Layout(app/components/ruby_ui/layout.rb): desktop sidebar, mobile sheet menu, flash, centered main column (same pattern as a typical RubyUI / hpees-style app). - Pages: Phlex classes under
app/views/(e.g.Views::Dashboard::Index). Zeitwerk maps folder names likerevenue_budgets/toViews::RevenueBudget::Index(notRevenueBudgets) — see Rails inflection inconfig/application.rb.
Domain models live under app/models/ (e.g. actual expenditures, revenue/expenditure budgets). Wire them into the dashboard and section pages as you build features.
| Command | Purpose |
|---|---|
bin/dev |
Foreman: web (Puma) + css (tailwindcss:watch) — recommended for development |
bin/rails server |
Rails only; CSS will not auto-rebuild |
bin/rails tailwindcss:build |
One-off Tailwind compile |
bin/rails db:prepare |
Create/migrate DB |
bin/rails db:reset |
Drop, create, migrate, seed (destructive) |
bin/rails test |
Minitest |
bin/rubocop |
Lint (RuboCop Omakase) |
bin/brakeman |
Security scan |
bundle exec bundler-audit |
Gem vulnerability audit |
Dockerfilebuilds the app;rails assets:precompileruns in the image andtailwindcss:buildis hooked toassets:precompilebytailwindcss-rails.- Kamal config:
config/deploy.yml.
Run bin/rails tailwindcss:build or use bin/dev. Ensure you are not adding a bare stylesheet_link_tag "tailwind" without guaranteeing the file exists.
- Confirm
app/assets/builds/tailwind.cssexists and is non-empty. - Restart the server after changing asset paths or initializers.
- Clear browser cache if asset digests changed.
bin/spring stopIf the repo includes AGENTS.md, follow that for Git/PR workflow and tooling conventions.
See repository root for a LICENSE file if one is added; otherwise treat usage as defined by the project owner.
以下為繁體中文說明,與上方 English 章節對應。
- Ruby 3.4.x(見
.ruby-version;本專案使用ruby-3.4.8) - Bundler
- Node:此專案非必須;Tailwind 由
tailwindcss-rails編譯(CSS 不必執行npm run) - 本機開發預設 SQLite(資料庫檔於
storage/) - Gemfile 含 PostgreSQL 驅動,若部署使用
DATABASE_URL可接 Postgres;本機若用 Postgres 請調整config/database.yml
bin/setup會安裝套件、執行 bin/rails tailwindcss:build、準備資料庫,並啟動 bin/dev(Rails + Tailwind 監聽)。
手動步驟:
bundle install
bin/rails tailwindcss:build
bin/rails db:prepare
bin/devdev- 執行
bin/rails tailwindcss:build,產生app/assets/builds/tailwind.css。若略過此步驟,頁面可開啟但幾乎沒有樣式。 - 開發時建議用
bin/dev,不要只跑bin/rails server,否則修改app/assets/tailwind/application.css時不會自動重編譯 CSS(需有tailwindcss:watch)。
| 項目 | 說明 |
|---|---|
| Rails 8.1 | Web 框架 |
| Propshaft | 自 app/assets 提供帶指紋的靜態資源 |
| tailwindcss-rails | 將 app/assets/tailwind/application.css 編譯為 app/assets/builds/tailwind.css |
Phlex(phlex-rails) |
以 Ruby 撰寫的 HTML/視圖,位於 app/views/ |
| RubyUI | 元件庫,位於 app/components/ruby_ui/ |
| Hotwire | 透過 importmap 使用 Turbo + Stimulus |
版面使用 stylesheet_link_tag :app,會連結所有存在的 app/assets/**/*.css(含 app/assets/builds/ 下的 Tailwind 產出)。若尚未建置 tailwind.css,不會因此拋出 Propshaft::MissingAssetError(只是暫時沒有樣式,執行 tailwindcss:build 即可)。
請勿單獨使用 stylesheet_link_tag "tailwind",除非你能保證每個環境(CI、Docker、新 clone)都有 app/assets/builds/tailwind.css。
主題色票、圓角、側欄等 CSS 變數定義在 app/assets/tailwind/application.css。
| 路徑 | 說明 |
|---|---|
/ |
儀表板 — 實際支出 |
/revenue_budgets |
收入預算(目前為占位頁) |
/expenditure_budgets |
支出預算(目前為占位頁) |
/settings |
設定(目前為占位頁) |
- 外殼:
app/views/layouts/application.html.erb以RubyUI::Layout(app/components/ruby_ui/layout.rb)包住內容:桌面側欄、行動版抽屜選單、flash、置中主內容欄(與常見 RubyUI/hpees 風格相同)。 - 頁面:
app/views/下的 Phlex 類別(例如Views::Dashboard::Index)。Zeitwerk 會將revenue_budgets/等資料夾對應到Views::RevenueBudget::Index(不是RevenueBudgets)— 見config/application.rb中的複數/單數設定。
網域模型在 app/models/(例如實際支出、收入/支出預算)。實作功能時再將其接到儀表板與各區塊頁面。
| 指令 | 用途 |
|---|---|
bin/dev |
Foreman:同時跑 web(Puma)與 css(tailwindcss:watch)— 建議日常開發使用 |
bin/rails server |
僅 Rails;CSS 不會自動重編譯 |
bin/rails tailwindcss:build |
單次編譯 Tailwind |
bin/rails db:prepare |
建立/遷移資料庫 |
bin/rails db:reset |
刪除並重建資料庫、執行 seed(具破壞性) |
bin/rails test |
執行 Minitest |
bin/rubocop |
程式風格檢查(RuboCop Omakase) |
bin/brakeman |
安全性掃描 |
bundle exec bundler-audit |
檢查套件已知漏洞 |
Dockerfile建置映像時會跑rails assets:precompile;tailwindcss-rails會在assets:precompile階段觸發tailwindcss:build。- Kamal 設定:
config/deploy.yml。
執行 bin/rails tailwindcss:build 或改用 bin/dev。請勿在未保證檔案存在時單獨使用 stylesheet_link_tag "tailwind"。
- 確認
app/assets/builds/tailwind.css存在且非空檔。 - 修改資源路徑或 initializer 後請重啟伺服器。
- 若資源指紋變更,可清除瀏覽器快取。
bin/spring stop若儲存庫含 AGENTS.md,請依其中說明進行 Git/PR 流程與工具約定。
若專案根目錄有 LICENSE 檔請依該檔;若無,則以專案擁有者定義之使用方式為準。