angularjs - Rails catch all route, excluding resources and HTML -
i using angular html5mode have rails routing set redirect failed requests root
# angular catch allow page refresh '*page' => "home#index"
this works fine, except when angular module requests missing template (/assets/templates/page.html example), when causes endless loop
how can tell rails catch routes, except things in /assets ?
i noticed quite old, found through google , wasn't happy answer here. since worked through myself share solutions.
use format parameter in route
get "/*path" => "home#index", format: false
simply disable format option wildcard path ignores requests format (e.g. css, js, png...)
use constraint in route
get "/*path" => "home#index", constraints: -> (req) { !(req.fullpath =~ /^\/assets\/.*/) }
specify constraint option simple lambda checking path value, not best regular expression shows idea i'm going here...
use format parameter in apps, constraints option lets pass in object, check out rails guide more info -> http://guides.rubyonrails.org/routing.html#advanced-constraints
Comments
Post a Comment