O
O
Ord EO2019-05-10 12:34:31
Ruby on Rails
Ord EO, 2019-05-10 12:34:31

How to display show immediately in Active Admin, without indexa?

I use ACTIVE ADMIN.
I created a model that has only a name and mail, when you go to active admin, this page is displayed on this model. 5cd5456e24abf962138041.png
I need the View to be displayed immediately, i.e. when you click on the link to the model, it was immediately displayed like this:
5cd5459e1cb0f337368847.png
How can this be done?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Alekseiev, 2019-05-10
@OrdeO

In fact, you just need to redefine the index action in the desired model. Suppose you have a model called Post. If you used the default setting for active admin your code might look like this. In the file "admin/post.rb":

ActiveAdmin.register Post do
  controller do
    def index
      ::Post.count < 1 ? redirect_to(new_admin_post_path) : redirect_to(admin_post_path(::Post.first.id))
    end
  end
end

The code may not be perfect, but it's enough.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question