action-controller

Guide Rails controller development with strong parameters and callback management.

5|Updated Jan 28, 2026
One-click install
npx skills add https://github.com/ThinkOodle/rails-skills --skill action-controller-thinkoodle
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: action-controller
Source: https://github.com/ThinkOodle/rails-skills/tree/main/skills/action-controller
Command: npx skills add https://github.com/ThinkOodle/rails-skills --skill action-controller-thinkoodle

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides expert guidance for writing correct, secure, and idiomatic Rails controllers, addressing common pitfalls like parameter permitting and callback ordering.

Core Features & Use Cases

  • Secure Parameter Handling: Safely permit nested parameters to prevent mass assignment vulnerabilities.
  • Efficient Callback Management: Structure before_action, after_action, and around_action for clear control flow.
  • Response Rendering & Redirection: Implement correct rendering, redirects, and flash messages, especially for Turbo.
  • Use Case: When building a new feature that involves user input via a form, use this Skill to ensure all parameters are securely permitted before they reach your models, and set up appropriate callbacks for authentication and authorization.

Quick Start

Use the action-controller skill to define a new create action for the Article model, ensuring strong parameters are used.

Frequently Asked Questions about action-controller

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I permit nested hashes and arrays using Rails strong parameters?

To permit nested hashes and arrays with Rails strong parameters, you must explicitly chain the `permit` method with nested keys and array scalar values to prevent mass assignment vulnerabilities. This ensures only safe input reaches your models.

What is the correct ordering for Rails before_action callbacks and filters?

Rails before_action callbacks execute in the order they are defined, halting the request chain if any callback renders or redirects. Proper callback ordering ensures authentication and authorization checks occur before controller actions run.

How do I render Turbo-compatible responses and flash messages in Rails controllers?

Rendering Turbo-compatible responses involves returning correct HTML or streaming formats alongside flash messages in your Rails controller redirects. This ensures seamless page updates and user notifications during Turbo Drive navigation.

How does CSRF protection work with sessions and cookies in Rails controllers?

CSRF protection in Rails controllers validates authenticity tokens tied to sessions and cookies to prevent forged requests. It is automatically enabled and secures state-changing actions from cross-site forgery attacks.

What is the best way to structure Rails controller responses for JSON and streaming?

The best way to structure Rails controller responses for JSON and streaming is to use explicit format blocks and rendering strategies. This allows efficient data serialization and progressive content delivery to the client.

Why are my Rails strong parameters not permitting fields correctly?

Rails strong parameters often fail to permit fields correctly due to unpermitted nested hashes or missing scalar definitions. You must explicitly declare permitted keys and array structures to avoid mass assignment errors.