ruby - Rails: Send request back to router -
i working on app cms-functionality client can match arbitrary paths articles.
now, use route globbing match html request , check in controller if have article show. if no article present, want send request route resolution flow, search other potential matches.
i imagine there should exception that, can't figure out. it's not routingerror
.
the configuration file: config/routes.rb
runs top-to-bottom when defining application routes. need define catch-all @ top of file.
i'd recommend using sort of constraint
(so can cache result). example, solution may like:
# config/routes.rb '*', to: 'article#show', constraints: articleconstraint.new # lib/article_constraint.rb class articleconstraint def matches? # trivial example... make better, e.g. use cacheing! article.exists?(name: request.path) end end
Comments
Post a Comment