rails-antipattern-homemade-keys-and-routes
Installation
SKILL.md
Antipattern: Homemade Keys and Routes
The smell
- Hand-rolled
get "show_post/:slug", to: "posts#show_by_slug"style routes - Custom controller methods named
show_by_slug,user_posts,do_publish link_to "...", "/show_post/#{p.slug}"(string URLs) because no helper exists- Resourceful concepts wearing custom URLs
Why it hurts
- No path/url helpers from
resources— every link is bespoke redirect_to @postdoesn't work- Polymorphic helpers (
form_with model: @post) break - Authorization scoping (
current_user.posts.find(params[:id])) becomes harder - New devs can't predict URLs from models