rails-conventions
/rails-conventions
Stosuje konwencje Rails firmy RoleModel tam, gdzie różnią się od domyślnych: komunikaty flash, statusy nieudanych zapisów, Simple Form i wzorce tras.
- Autor
- rolemodel ↗
- Repozytorium
- skills ↗
- Licencja
- MIT
- Ostatnia zmiana repozytorium
- 27.10.2026
Ocena i bezpieczeństwo
- Pliki w paczce
- 1
- Skrypty
- 0
- Komentarze HTML
- 0
- Adresy URL w SKILL.md
- 0
Brak sygnałów. Repozytorium zmienione 27.10.2026, bez odwołań do wycofanych modeli i API.
MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.
Co robi i kiedy
Stosuje konwencje Rails firmy RoleModel tam, gdzie różnią się od domyślnych: komunikaty flash, statusy nieudanych zapisów, Simple Form i wzorce tras.
Wyzwalacze z opisu
Oryginalny opis (EN)
RoleModel's Rails conventions where they differ from what an agent writes by default: flash wording, the status for failed saves, Simple Form for every form, how route concerns pass the parent type, and two gotchas (`params.expect` with nested attributes, and Lexxy rich-text change events). Use when writing or reviewing a Rails controller, route, form, or view in a RoleModel app. Also use when the user says things like "add a controller for", "build the form for", "add routes for", "add comments to", "why isn't my nested form saving", or "review this controller".
Jak działa
- Rules
- Gotchas
Podgląd SKILL.md
---
name: rails-conventions
description: >-
RoleModel's Rails conventions where they differ from what an agent writes by default: flash wording, the status for failed saves, Simple Form for every form, how route concerns pass the parent type, and two gotchas (`params.expect` with nested attributes, and Lexxy rich-text change events). Use when writing or reviewing a Rails controller, route, form, or view in a RoleModel app. Also use when the user says things like "add a controller for", "build the form for", "add routes for", "add comments to", "why isn't my nested form saving", or "review this controller".
metadata:
triggers: "rails controller, controller action, routes.rb, route concern, rails form, simple form, simple_form_for, flash message, params.expect, strong params, nested attributes, lexxy, rails view"
---
# Rails Conventions
This skill only covers what an agent got wrong without it in baseline tests. Everything else is standard Rails 8 practice, which the agent already follows. Where a project's own code or `docs/conventions/` disagrees, follow the project.
## Rules
- **Flash wording:** `notice: 'Successfully Created Widget'`, `'Successfully Updated Widget'`, `'Successfully Deleted Widget'`. Use `alert:` for failures.
- **Failed saves:** `render :new, status: :unprocessable_content`, never `:unprocessable_entity`, which is the deprecated name for the same 422.
- **Forms:** always `simple_form_for` and `simple_fields_for`, never `form_with` or `form_for`. Non-model forms use a symbol: `simple_form_for :search, url: widgets_path, method: :get`, which nests params under `:search`.
- **Route concerns pass the parent type with `parent_resource.name.classify`**, not a hard-coded string or a concern option:
```ruby
concern :commentable do
resources :comments, commentable_type: parent_resource.name.classify
end
```
The controller turns it back into the record with `resource_for(:commentable_type)` from `rolemodel_rails`, called only on collection actions. Read `polymorphic-parent-resources` before writing that controller.
- **Dynamic forms** (dependent selects, conditional fields) use the `turbo_form` gem. Read `dynamic-forms`.
- **Mounted engines that expose data or controls** (Sidekiq Web, PgHero, Blazer) go behind an admin-only route constraint, and dev-only engines (Letter Opener Web) mount only outside production. This one is a safety rule, kept even though the baseline tests didn't cover it.
## Gotchas
- **`params.expect` needs double brackets for nested attributes.** `parts_attributes: [[:id, :name, :_destroy]]` matches the indexed hash that `fields_for` submits. The single-bracket form `parts_attributes: %i[id name _destroy]` silently drops every nested record under `expect`, though it works under `permit`.
- **Lexxy rich-text fields report edits with a `lexxy:change` event.** Anything that reacts to form edits by listening for `change` or `input` (auto-save, unsaved-changes warnings, dynamic form triggers) must listen for `lexxy:change` too, or edits in the editor are missed.
Wersje
| Repozytorium | Wynik | Licencja |
|---|---|---|
| Ta strona · rolemodel/skills | 100 | MIT |
| ethos-link/rails-conventions | 100 | MIT |
Migawka bazy z 13.11.2026 · wersja paczki 82eb280eafa1 (skrót SHA-256 całej paczki)
Pobrania w ostatnich 30 dniach: 0 · ranking
Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.
Podobne skille
- 95rails-action-controller-patterns
Opisuje wzorce Action Controller w Rails: routing, filtry, strong parameters i konwencje REST. - 100rails
Dostarcza konwencje i dobre praktyki pisania oraz przeglądu kodu w Ruby on Rails: ActiveRecord, ActiveJob, migracje, concerns i request specs. - 86ruby-on-rails
Podpowiada konwencje i wytyczne Ruby on Rails przy pracy z plikami rb. - 100rails
Prowadzi przez tworzenie aplikacji Rails: modele z migracjami, endpointy API, logowanie, zadania w tle, testy i aktualizację do Rails 8. - 95rails-cto-restful
Podpowiada, jak pisać kontrolery RESTful w Rails 8: akcje, trasy, zagnieżdżone zasoby i reguły CRUD. - 100polymorphic-parent-resources
Obsługuje zasób potomny podpięty do wielu rodziców w Rails jednym kontrolerem, z concern i resource_for z gemu rolemodel_rails.