Skip to content

Instantly share code, notes, and snippets.

Controller Migration Guidelines

The current controllers use actions (files defined in app/actions directory) to handle the business logic of the application currently. So a Posts::CommentsController#create action will call a Posts::Comments::CreateAction defined in /app/actions/posts/comments/create_action.rb. The migration goal is to migrate these controllers to use a custom form object and policy modules instead of these actions. If i have a Posts::CommentsController the policy object should be Posts::CommentsPolicy and it should be defined in app/policies/posts/comments_policy.rb. For the create action of that controller they should be a Posts::Comments::CreateForm form object that should live in app/forms/posts/comments/create_form.rb. These guidelines define the patterns and principles for migrating from the "Action" pattern to the "Form Object & Policy Object" pattern. These practices ensure the codebase remains DRY, highly testable, and robust.

Core Principle: Form-Driven State Changes

All n

@blafri
blafri / selenium_hack.rb
Last active November 7, 2025 15:23
Hack to fix browser size issues with the current version of chrome driver that is not respecting the screen_size option.
# There is a bug with the chrome driver that does not respect the screen_size option, so we have this hack
# to resize the window to the proper size after it visits a page.
#
# This should be removed in the future once the bug is fixed.
#
# See: https://github.com/SeleniumHQ/selenium/issues/15827
def visit(...)
super.tap do
page.driver.browser.manage.window.resize_to(1400, 800)
end