Rails ActiveAdmin - change the after update redirect_to

前端 未结 6 1189
青春惊慌失措
青春惊慌失措 2020-12-31 04:01

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

6条回答
  •  执念已碎
    2020-12-31 04:36

    At the current moment accepted answer leads to ignoring validation errors.

    This works for me with the latest versions of ActiveAdmin and Rails:

    controller do
    
      def update
        update! do |format|
          format.html { redirect_to collection_path } if resource.valid?
        end
      end
    
      def create
        create! do |format|
          format.html { redirect_to collection_path } if resource.valid?
        end
      end
    
    end  
    

提交回复
热议问题