mirror of
https://github.com/opf/openproject.git
synced 2026-06-13 19:20:00 +00:00
72f584942d
This reverts commit 7d49707c4b.
1.3 KiB
1.3 KiB
App
Directory Structure
app/components/- ViewComponent-based UI components (Ruby + ERB)app/contracts/- Validation and authorization contractsapp/controllers/- Rails controllersapp/models/- ActiveRecord modelsapp/services/- Service objects (business logic)app/workers/- Background job workers
Code Style Guidelines
Ruby
- Follow Ruby community style guide
- Use service objects for complex business logic (return
ServiceResult) - Use contracts for validation and authorization
- Keep controllers thin, models focused
- Document with YARD
- Write RSpec tests for all new features
- Work package identifiers:
WorkPackage.find("PROJ-42")resolves semantic identifiers transparently. Usefind_by_display_idonly when input could legitimately be numeric OR semantic (controllers, URL-driven components, macro resolvers). Low-level code (queries, filters, services) should stick tofind_by(id:)with primary keys. Seeapp/models/work_package/semantic_identifier/finder_methods.rb.
Templates
- Use ERB for server-rendered views
- Use ViewComponents for reusable UI (with Lookbook previews)
- Lint with erb_lint before committing
Translations
- UI strings must use translation keys (never hard-coded)