Grant Birchmeier
Grant Birchmeier

Reputation: 18484

ActiveAdmin: Can I redirect the user to the index after they create/edit something?

My customer (who is nontechnical) has asked me if I can change an ActiveAdmin form to redirect to the index instead of the show-item page after she submits (assuming no form errors).

Is that possible? How would I do that?

Upvotes: 4

Views: 1160

Answers (1)

Grant Birchmeier
Grant Birchmeier

Reputation: 18484

Well, that was a lot easier than I expected.

For my Articles model,

ActiveAdmin.register Article do

  ...

  controller do
    def create
      create! { admin_articles_url }
    end 
    def update
      update! { admin_articles_url }
    end 
  end 

  ...

end

That's it!

This is implemented by the inherited_resources gem, which Active Admin uses. My code changes are actually right from that project's readme.

Upvotes: 4

Related Questions