How are we doing? Please help us improve Stack Overflow. Take our short survey

Questions tagged [routes]

Questions about mapping URLs to Controllers and Actions.

routes
Filter by
Sorted by
Tagged with
33 votes
3 answers
8k views

How to dynamically call routes helper in rails?

For example, I have constructed a string called "new_work_path", now I want to call that helper as a method. I've tried send("new_work_path", vars) and calling the same send from many objects. But I ...
gtr32x's user avatar
  • 2,053
33 votes
2 answers
34k views

NodeJS Express - separate routes on two ports

I have an express server, and while building it created several "helper" functions on their own routes. I'd like those routes to be accessed on a different port. Is there anyway to do this in express?...
JKC's user avatar
  • 771
33 votes
1 answer
12k views

What is the difference between "express.Router" and routing using "app.get"?

I have an app with following code for routing: var router = express.Router(); router.post('/routepath', function(req, res) {}); Now I have to put routing code in different files so I tried to use ...
XIMRX's user avatar
  • 2,160
32 votes
6 answers
7k views

play framework2: remove trailing slash from urls

In play framework 1, you could use in the routes file something like this (check documentation at http://www.playframework.org/documentation/1.2.5/routes#syntax) GET /clients/? Clients....
opensas's user avatar
  • 61.7k
32 votes
2 answers
18k views

Redirect from one Area's action to a action in the "root"-area?

I use the latest version of ASP.Net MVC 2 RC. My question is, how do I redirect from one action that's in the "Blog"-area to the index-action in the home-controller that exists in the "root" of my ...
Mickel's user avatar
  • 6,688
32 votes
1 answer
35k views

Rails: redirect with params

What's the best way to pass some params along with a redirect? I saw examples that said if you just add them to your redirect hash they would pass along with the request, but that doesn't seem to ...
Andrew's user avatar
  • 42.8k
32 votes
5 answers
11k views

Adding ID and title to URL slugs in ASP.NET MVC

How do you redirect a request in ASP.NET MVC to its correct canonical version if part of the URL is missing? Using Stack Overflow as an example, the site adds the question title to the end of its ...
wycleffsean's user avatar
  • 1,377
32 votes
2 answers
14k views

How to serve index.html with web api selfhosted with OWIN

Should be an easy question, just can't find the answer. I have an SPA (AngularJS) with web api which is self hosted with Owin. I use Nancy to serve the page, but I would like to get rid of Nancy and ...
Burjua's user avatar
  • 12.6k
32 votes
1 answer
29k views

Is it possible to bind a [routerLink] to a div? Angular 2+

I am new to Angular and I have found no clear answers on this subject no matter what I search for. This is currently working: <div class="col-sm" (click)="brandListRoute()"> which directs to ...
Daniel Bailey's user avatar
32 votes
2 answers
66k views

How do I do geocoding and routing with OpenStreetMap? [closed]

Because Google Maps API is not available in Israel (see here) I want to use OpenStreetMap. I'm confused by all the different ways to do geocoding, i.e. finding lat,long for an address. I'm also ...
GilShalit's user avatar
  • 6,291
31 votes
1 answer
49k views

Flask middleware for specific route

I made API Server with Python Flask-RESTful. My system use token authentication for verify permission. So, I added middleware for verify token. For example, code like this, [middleware.py] class Test(...
Hide's user avatar
  • 3,239
31 votes
5 answers
77k views

redirect to 404 page automatically at laravel 5.4

i made simple resume site with laravel 5.4 and i wanna if users type anything except my site name and my site.com/panel automatically redirect to 404 page. how can i do that? is there any route to ...
Siros Fakhri's user avatar
  • 2,263
31 votes
8 answers
172k views

Redirect::route with parameter in URL in Laravel 5

I'm developing a Laravel 5 app, I have this route Route::get('states/{id}/regions', ['as' => 'regions', 'uses' => 'RegionController@index']); In my controller, after I make a post call ...
Bellots's user avatar
  • 1,753
31 votes
9 answers
28k views

Route to static file in Play! 2.0

I'm trying to make a route to a specific static file but everything I'm trying ends with an error. I've made 3 different attempts: 1. GET /file staticFile:/public/html/file.html The error I get: ...
Nitzan Tomer's user avatar
31 votes
6 answers
28k views

Angular router url returns slash

I'm trying to get the current router path by using Router, but when i do console.log(this.router.url) it returns "/", although i'm on the "/login". But when i'm consoling the entire this.router object,...
sandum's user avatar
  • 781
31 votes
1 answer
46k views

Where's root_path or root_url?

In rails, there are a lot of helpers to direct our actions, like collections_path new_member_path edit_member_path and so on. But where is the root? Is there a helper always points to my homepage?
Lai Yu-Hsuan's user avatar
  • 27.8k
31 votes
2 answers
6k views

How to write controller tests when you override devise registration controller?

I wish to override the Devise::RegistrationsController to implement some custom functionalality. To do this, I've created a new RegistrationsController like so: # /app/controllers/...
David Tuite's user avatar
  • 22.4k
31 votes
2 answers
63k views

How to display a route between two geocoords in google maps? [duplicate]

Possible Duplicate: J2ME/Android/BlackBerry - driving directions, route between two locations I'm just writing an App for displaying the route between two coords (lat, long) in google maps view. ...
poeschlorn's user avatar
  • 12.3k
31 votes
4 answers
21k views

How can I access a service running on WSL2 from inside a Docker container?

I am using Windows 10 1909 and have installed WSL2, using Ubuntu 20.04, the 19.03.13-beta2 docker version, having installed Docker for Windows Edge version using the WSL2 option. The integration is ...
donmartin's user avatar
  • 1,853
31 votes
5 answers
130k views

Error: Cannot match any routes. URL Segment:

I am trying to follow this tutorial http://onehungrymind.com/named-router-outlets-in-angular-2/ but I am getting the error. EXCEPTION: Uncaught (in promise): Error: Cannot match any routes. URL ...
user avatar
30 votes
5 answers
19k views

How can I redirect a user's home (root) path based on their role using Devise?

I'm working on a project management app, and in the app, I have project_managers and clients. I'm using Devise and CanCan for authentication/authorization. At what point after login should I be ...
Mark's user avatar
  • 315
30 votes
7 answers
94k views

Detect browser refresh in an Angular project

I want to detect when a page is refreshed using a router in my single-page application (Angular project). Is there an alternate way?
Khaled Ayed's user avatar
  • 1,246
30 votes
3 answers
55k views

Laravel Route apiResource (difference between apiResource and resource in route)

I'm using apiResource in Route which is using (index, create, show, update, destroy) methods in exampleController. When I would like to use show method the route wont work. what shall I do? I think it ...
Shokouh Dareshiri's user avatar
30 votes
8 answers
34k views

React Router Redirect drops param

I am using the next version of React Router, and it seems to be dropping params. I expect the redirect below to retain the value of channelId, but the to route uses the literal string ":channelId" in ...
Matt Norris's user avatar
  • 8,706
30 votes
2 answers
51k views

Laravel: Get URL from routes BY NAME

I'm trying to do something a little different and I couldn't find any way to do it. Maybe my approach is wrong but either way I figured I might find some help here. I have a Laravel 5 project and you ...
brunomayerc's user avatar
30 votes
2 answers
10k views

routes in rails - removing actions when setting up a resource

I've setup a simple app and added a scaffold to do some of the work for me (I'm a noob). resources :cars How do I remove certain actions from the routes? And remove the corresponding urls? For ...
Finnnn's user avatar
  • 3,540
30 votes
2 answers
27k views

Angular 2 feature module routing example

As far as Angular 2 routing goes, I've mostly been able to find examples of the scenario where there's exactly one routing file for the whole application. I'd like to see an example of using not just ...
Jason Swett's user avatar
  • 44.4k
30 votes
2 answers
21k views

How to get RouteData by URL?

I need to get RoutData by given URL string in ASP.NET MVC application. I've found the way that I need to mock HttpContextBase based on my URL string and then pass it to RouteTable.Routes.GetRouteData(...
Serge S.'s user avatar
  • 4,905
30 votes
2 answers
39k views

How to use "useRouter()" from next.js in a class component?

I was trying to get the queries from my url pattern like localhost:3000/post?loc=100 by using useRouter() from "next/router" and fetching some data using that id from my server. It worked when I used ...
Shakirul Hasan's user avatar
30 votes
4 answers
24k views

Angular 2 Activatedroute params not working in Service or outside <router-outlet>

I have a very strange problem: index.html <navigation-menu *ngIf="isLoggedIn"></navigation-menu> <div class="content-wrapper" [ngClass]="{'fullContent' : !isLoggedIn}"> <...
Cabe Skuriles's user avatar
29 votes
10 answers
73k views

Troubleshooting "The controller for URI is not callable" error

I'm working on Symfony 2.3 and I declared a new route and new controller, but when I call this controller from the browser I get this error: The controller for URI "/user/1" is not callable. ...
Angelo Giuffredi's user avatar
29 votes
4 answers
29k views

Can I rake the routes for a specific resource?

I've been grepping the output of rake routes forever and it just dawned on me that someone must know a better way to inspect routes. I have a resource in my routes.rb name account_groups: resources :...
spinlock's user avatar
  • 3,837
29 votes
4 answers
35k views

Rails - link_to, routes and nested resources

As my understanding on nested resources, on edge Rails, should not link_to 'User posts', @user.posts point to /users/:id/posts ? The routes.rb file contains map.resources :users, :has_many => ...
knoopx's user avatar
  • 17.2k
29 votes
1 answer
15k views

Redirect (301) one route to another from routing.yml in Symfony2

I know this is probably trivial, but I couldn't find anything on the web or in the Symfony2 reference. How do I redirect one route to another from routing.yml (with 301 status code)? I'm looking for ...
lemon24's user avatar
  • 329
29 votes
4 answers
367k views

How to flush route table in windows?

I am trying to write a program that changes the default gateway of network time by time. But it seems that there are caches on the route table in every process so that I cannot control the network ...
jay's user avatar
  • 1,041
29 votes
1 answer
21k views

Rails 3 routing - passing params from routes.rb

In rails 2.3.5 you could do something like this inside the routes.rb file: map.root :controller => "pages", :action => "show", :id => 3 In rails 3 I haven't found any way to pass a specific ...
JohnDel's user avatar
  • 2,102
29 votes
1 answer
8k views

Express.js or angular for handling routes in a MEAN application?

I am totally new to everything Nodejs/express/angular, and I just ran into a question that bothers me. When you have a MEAN stack, it seems that routes can be handled by both Express.js and Angular. ...
Lars Holdgaard's user avatar
29 votes
2 answers
42k views

How to add prefix to all node / express routes

Does anyone know of a way to configure express to add a prefix before all routes automatically? for example, currently I have: / /route1 /route2 However, I want to add a prefix like: /prefix/ /...
Trung Tran's user avatar
  • 13.4k
29 votes
2 answers
25k views

Angular 2, RC5 router-outlet inside another router-outlet

I'm trying to make one project with one router-outlet inside another router-outlet: It will work like this: In the first router-outlet it will have two views: auth component (/login) admin ...
Thiago Yoithi's user avatar
29 votes
5 answers
37k views

Next.js - Shallow routing with dynamic routes

When attempting shallow routing with a dynamic route in Next.js the page is refreshed and shallow ignored. Seems a lot of people are confused about this. Say we start on the following page router.push(...
AndrewMcLagan's user avatar
29 votes
1 answer
17k views

Node.js Express route naming and ordering: how is precedence determined?

Say I've got a few GET routes on my Express application: // music albums app.get('/api/albums', routes.albums.getAlbums); app.get('/api/albums/:id', routes.albums.getAlbum); app.get('/api/albums/...
user avatar
28 votes
3 answers
27k views

(Vue.js) Same component with different routes

I would like to use the same component for different routes in a Vue.js application. I currently have something like this: main.js const routes = [ { path: '/route-1', name: 'route-1', ...
Moisés Pio's user avatar
28 votes
5 answers
34k views

Multiple pattern in single symfony routing

How to make multiple pattern in single Symfony routing? Normally we have a routing as blog: pattern: / defaults: { _controller: AcmeBlogBundle:Blog:index, page: 1 } Is it possible to ...
Justin John's user avatar
  • 9,378
28 votes
7 answers
15k views

Css and Scripts don't work until the user log in the website - Asp.NET MVC 3 Web Site

I've a asp.net mvc 3 site and i publish it in iis 7.5 (framework 4.0), and the problem is that the css and the scripts don't work util the user log in the website. So: The website was created like ...
Vinicius Ottoni's user avatar
28 votes
2 answers
16k views

Rails3 Routes - Passing parameter to a member route

I would like to pass an extra parameter to a member route of a resource something like: resources :events do member do get 'register/:participant_type_id' end end I could only accomplish it ...
Diogo's user avatar
  • 283
28 votes
1 answer
19k views

Rails: Anchor option and link_to

I have a link_to method in Rails link_to("feedback", meetings_url(:anchor => "sometext")) => The above code produces: <a href="/p/meeting/?scroll_to=sometext">feedback</a> I thought ...
Manjunath Manoharan's user avatar
28 votes
4 answers
21k views

How to set class based on current route name/controller

Trying to set a class based on my current controller or current route (URL Segment 1). something like <body class="{{controllerName}}"> That way in case I need to target separate pages for ...
Christopher Marshall's user avatar
28 votes
1 answer
20k views

How can I set default parameter value in routing in rails 3

How can I set default parameter value in routing in Rails 3. For example I have this route match ':slug/:id/:direction' => 'quiz#show', :as => :quiz_details, :direction => "next" and I want ...
Zahid's user avatar
  • 1,820
28 votes
1 answer
10k views

Proper way to organize myapp/routes/*

Using latest stable node.js and express from npm, I've created my first express project. The default generated app defines routes/index.js, which contains a single route that renders the default ...
Gabriel Bauman's user avatar

1
3 4
5
6 7
669