Search code examples
ruby-on-railsroutesrails-routingrails-activestorage

Devise scoped member routes issue


I'm using devise for sign up and ActiveStorage for image upload. For the delete/purge function to work I have this route

  devise_scope :user do 
    scope module: :users do
      resources :registrations do
        member do
          delete :delete_image_attachment
        end
      end
    end
  end

But another place in my routes file I have this route

  devise_for :users, controllers: {:registrations => "users/registrations" 
  }

It makes some of my pages not working. I have read somewhere that it's because registrations are declared two times. How can I make it work? Any help would be much appreciated


Solution

  • If you use resources :registrations, only: [] do... that will create the parent route that you need without overwriting any of the routes provided by devise. Allowing you to make your nested routes :D