1

I placed a catch all route at the bottom of my route file. Annoyingly, Active Storage requests are also directed to the same action. I don't want that.

I have read this on SO and this issue on Github that suggest adding a constraint to the route.

Rails.application.routes.draw do
#...
  get "/*slug" => "profiles#show",
      param: :slug,
      as: "profile",
      contraints: lambda { |req|
        req.path.exclude? "rails/active_storage"
      }
end

However, this isn't working for me. ActiveStorage requests are still going to profiles#show. What is wrong with my constraint? Have I missed anything obvious?

user3574603
  • 3,364
  • 3
  • 24
  • 59

1 Answers1

3

You have a typo.

It should be constraints: instead of contraints:.

Marian13
  • 7,740
  • 2
  • 47
  • 51