Rails ActiveAdmin - change the after update redirect_to

Marcelo picture Marcelo · Jan 28, 2012 · Viewed 18.7k times · Source

I have a Feature page that belongs to the Car page. That is working exactly how I want to, except for one thing.

After creating, updating or destroying, I want the page to be redirected to the admin_car_path(car) instead of the defaults admin_car_feature_path(car,feature) for create and update and admin_car_features_path(car).

I unsuccessfully searched for that.

ActiveAdmin.register Car do
end

ActiveAdmin.register Feature do
  belongs_to :car
end

TIA

Answer

nazar kuliyev picture nazar kuliyev · Mar 18, 2014

right code for updating without skipping validation

controller do
  def update
    super do |success,failure|
      success.html { redirect_to collection_path }
    end
  end
end