Dry-Rails + ActionController::API

Hi all,

Since dry-rails include controller only in the ApplicationController, its not possible to use safe_params and others methods if you are working in a Rails API when you controller inherits from ActionController::API. Whats is the best way to handle this? (I tried both solutions and works)

  1. include helpers the ActionController::API in order to works “out-of-the-box” for Rails in API mode (I could start a PR for this if its a good idea)
    like:
    start do
    ActionController::Base.include(Dry::Rails::Features::ControllerHelpers)
    ActionController::API.include(Dry::Rails::Features::ControllerHelpers)
    end

  2. include Dry::Rails::Features::ControllerHelpers in my controllers

Hey there, I didn’t know about ActionController::API - please report an issue about it in dry-rails repository, this should be supported OOTB.

Cool!

Done.

1 Like