ActiveAdmin - redirect_to root_path或index

时间:2015-08-11 06:39:00

标签: ruby-on-rails ruby routes activeadmin

我有以下代码:

ActiveAdmin.register HealthCoach do

controller do
def create
  health_coach = HealthCoach.new(user_params)
  health_coach.uid = health_coach.email
  if health_coach.save 
    # I want to redirect_to admin/health_coaches#index
  end
end

以下是我的路线:

                                           admin_root GET    /admin(.:format)                                                          admin/health_coaches#index
                    batch_action_admin_health_coaches POST   /admin/health_coaches/batch_action(.:format)                              admin/health_coaches#batch_action
                                 admin_health_coaches GET    /admin/health_coaches(.:format)                                           admin/health_coaches#index
                                                      POST   /admin/health_coaches(.:format)                                           admin/health_coaches#create
                               new_admin_health_coach GET    /admin/health_coaches/new(.:format)                                       admin/health_coaches#new
                              edit_admin_health_coach GET    /admin/health_coaches/:id/edit(.:format)                                  admin/health_coaches#edit
                                   admin_health_coach GET    /admin/health_coaches/:id(.:format)                                       admin/health_coaches#show
                                                      PATCH  /admin/health_coaches/:id(.:format)                                       admin/health_coaches#update
                                                      PUT    /admin/health_coaches/:id(.:format)                                       admin/health_coaches#update
                                                      DELETE /admin/health_coaches/:id(.:format)                                       admin/health_coaches#destroy

我试过了redirect_to '/admin',但它没有用。有没有人知道如何重定向到admin/health_coaches#index

1 个答案:

答案 0 :(得分:1)

redirect_to( admin_health_coaches_path ) and return if health_coach.save