davideghz
davideghz

Reputation: 3685

Rails ActiveAdmin - edit all new actions

I need to override all the new actions of several models in AA. Currently I am overriding the models one by one, so I have a lot of duplicated code.

How can I edit all the new actions in one shot?

Just to give some background, I'm doing this in each AA resource file:

controller do
  def new
    # things
  end
end

Upvotes: 0

Views: 46

Answers (1)

fabOnReact
fabOnReact

Reputation: 5942

you should create a module and write your methods in that module, then include the module in every controller

class YourController < ApplicationController
  include YourControllerConcern
  # rest of the controller codes
end

but read the full original answer which I am quoting, that has additional info

while if you never used include this is a good explanation of what it does and this is a complete guide about include and extend

Upvotes: 1

Related Questions