Last Updated: July 25, 2019
·
5.825K
· sadfuzzy

ActiveAdmin custom routes

# admin/posts.rb
ActiveAdmin.register Post do
  controller do
    def first_page
      if current_admin_user.is_partner? && !current_admin_user.company
        redirect_to :new_admin_post
      else
        redirect_to :admin_posts
      end
    end
  end
end
# routes.rb
Rails.application.routes.draw do
  get '/admin/posts/first_page', to: 'admin/posts#first_page', as: :admin_posts_first_page
  ActiveAdmin.routes(self)
end