Colin Soleim
Colin Soleim

Reputation: 57

Active Admin Call Custom Method in Model instead of Default

I am currently having a problem customizing active admin in my Rails 4 application. In my app, I have a custom method in the model that builds tournaments and also the entries and rounds associated with them. If I only call the Tournament#create function, then none of these entries/rounds get created.

In active admin, is it possible to change the default buttons on the creation form so that it calls my custom function and not the default function?

Thank you very much!

Upvotes: 0

Views: 2597

Answers (1)

nistvan
nistvan

Reputation: 2960

You have to override the create/update/new action:

ActiveAdmin.register YourModel do

  controller do

    def create
      # your custom logic

    end
  end

end

ActiveAdmin uses InheritedResources: https://github.com/josevalim/inherited_resources#overwriting-actions

Upvotes: 1

Related Questions