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?
You have a typo.
It should be constraints:
instead of contraints:
.