Omar Lahlou
Omar Lahlou

Reputation: 1000

ActiveAdmin - redirect_to root_path or index

I have the following code:

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

Here are my routes:

                                           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

I tried redirect_to '/admin'but it didn't work. Does anyone have an idea about how to redirect to admin/health_coaches#index?

Upvotes: 1

Views: 700

Answers (1)

Brad Werth
Brad Werth

Reputation: 17647

redirect_to( admin_health_coaches_path ) and return if health_coach.save

Upvotes: 1

Related Questions