Rails ActiveAdmin - change the after update redirect_to

前端 未结 6 1200
青春惊慌失措
青春惊慌失措 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:23

    Current answer is skipping validations. Some of the other answers are working but partially correct (incorrect use of super or manually validating resource).

    Most updated "proper" way to redirect with AA after create and udpate:

    controller do
      def create
        create! do |success,failure|
          success.html { redirect_to collection_path, notice: "#{resource.model_name.human} was successfully created." }
        end
      end
      def update
        update! do |success,failure|
          success.html { redirect_to collection_path, notice: "#{resource.model_name.human} was successfully updated." }
        end
      end
    end
    

提交回复
热议问题