routing

Express routes parameter conditions

时光总嘲笑我的痴心妄想 提交于 2019-12-28 05:02:35
问题 I have a route on my Express app that looks like this: app.get('/:id', function (request, response) { … }); The ID will always be a number. However, at the moment this route is matching other things, such as /login . I think I want two things from this: to only use this route if the ID is a number, and only if there isn't a route for that specific paramater already defined (such as the clash with /login ). Can this be done? 回答1: Expanding on Marius's answer, you can provide the regex AND the

Howto allow “Illegal characters in path”?

一个人想着一个人 提交于 2019-12-28 04:01:07
问题 I have a MVC.NET application with one route as follows: routes.MapRoute("member", "member/{id}/{*name}", new { controller = "member", action = "Details", id = "" }, new { id = @"\d+" }); Thus, a link could be something like this: http://domain/member/123/any_kind_of_username This works fine in general but if the path contains illegal characters (e.g. a double qoute: http://domain/member/123/my_"user"_name) I get a "System.ArgumentException: Illegal characters in path." After much googling the

:as in rails routes.rb

拟墨画扇 提交于 2019-12-28 03:32:21
问题 In config/routes.rb , I tried both: root :to => 'things#index', :as => 'things' and root :to => 'things#index' When I hit http://localhost:3000/ , both approaches work, and nothing seems to be different. What is the :as option used for? 回答1: The :as option forms a named route. Usually it's used in a non-root route. For example: match '/search' => 'search#search', :as => 'search' # SearchController#search You could then do something like: <%= link_to search_path, 'Click Here to Search!' %>

Rails routing to handle multiple domains on single application

不羁的心 提交于 2019-12-27 12:10:45
问题 I've been unable to find a workable solution to this problem, despite several similar questions here and elsewhere. It seems likely that this question hasn't been answered for Rails 3, so here goes: I have an application that currently allows users to create their own subdomain that contains their instance of the application. While in Rails 2 you were best served using the subdomain-fu gem, in version 3 it's dramatically simpler, as per the Railscast -- http://railscasts.com/episodes/221

Angular 2 nested module with own routes

家住魔仙堡 提交于 2019-12-25 16:53:39
问题 I have a project on Angular 2 that have this structure: ++ / --- app.module.ts +++ dashboard ---- dashboard.module.ts ---- dashboard.routes.ts ++++ adminarea ----- adminarea.module.ts ----- adminarea.routes.ts ++++++ user ------- usermanagement.component.html ------- usermanagement.component.ts ++++ home ++++ user So, on my app.module.ts i import dashboard.module.ts . On dashboard.module.ts i have the main route app. On dashboard.component.html i have <router-outlet></router-outlet> On this

What's the correct way to update model and URL?

不打扰是莪最后的温柔 提交于 2019-12-25 16:43:31
问题 Suppose I've got following elements on the same page: Filters panel (something similar to http://www.imdb.com/search/name) Items based on filter options I want to implement following logic: URL should contain applied filter data in path ( /appliedOptionA/appliedOptionB ) When user opens site app get filter data from URL, updates filter panel and items panel When user changes filters app updates URL and refreshes items First idea: configure ng-router, get filter data as param, convert data to

How do I create a link/route directly to a scope?

偶尔善良 提交于 2019-12-25 15:18:39
问题 So I have a Post model, that has these scopes: scope :unconfirmed, -> { where( status: "unconfirmed") } scope :corroborated, -> { where( status: "corroborated") } scope :confirmed, -> { where( status: "confirmed") } What I want to do is when someone goes to posts/confirmed it shows all the posts scoped to confirmed. What is the most elegant way to do this? Also, how do I create a path for each scope in my routes.rb ? Edit 1 I know one way to do this is to simply create an action in my posts

How do I create a link/route directly to a scope?

穿精又带淫゛_ 提交于 2019-12-25 15:17:23
问题 So I have a Post model, that has these scopes: scope :unconfirmed, -> { where( status: "unconfirmed") } scope :corroborated, -> { where( status: "corroborated") } scope :confirmed, -> { where( status: "confirmed") } What I want to do is when someone goes to posts/confirmed it shows all the posts scoped to confirmed. What is the most elegant way to do this? Also, how do I create a path for each scope in my routes.rb ? Edit 1 I know one way to do this is to simply create an action in my posts

Multiple controller types were found that match the Requested URL

自作多情 提交于 2019-12-25 14:45:23
问题 I have enable attribute routing in route config file and I have declare attribute routing as [RoutePrefix("receive-offer")] public class ReceiveOfferController : Controller { // GET: ReceiveOffer [Route("{destination}-{destinationId}")] public ActionResult Index(int destinationId) { return View(); } } public class DestinationController : Controller { [Route("{country}/{product}-{productId}")] public ActionResult Destination(string country, string product, int productId) { return View(); } }

SAPUI5 Routing - Difference between controlId and targetControl

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-25 08:47:07
问题 In my routing configuration I can either set the property " controlId " or " targetControl " to specify the ID of the control where I want to put my new view. The only difference I figured out so far is that it seems that " controlId " has a higher priority. Means: If I specify both controlId is used. Despite that, is there any difference between these keys or are they synonyms? The same goes for " targetAggregation " and " controlAggregation "? I've read a lot of SAP documentation but I