Questions tagged [routes]

Questions about mapping URLs to Controllers and Actions.

MVC web application (like Ruby on Rails, ASP.NET MVC, etc) uses routes to map an arbitrary URL to a specific controller/action.

For example

http://example.com/foo/bar/23

Might pass an id 23 to controller foo, action bar.

Unusual URLs could also be mapped

Given controller places and intended action list, we can use routes to allow this URL:

http://example.com/my/places
32975 questions
36
votes
4 answers

How to use Rails named route helpers with parameters?

given this route match 'posts/hello/:name/:title' => 'post#show', :as => :hello what are the ways that I can call hello_path ? if i call hello_path(@post), what does it try to do? I was hoping that the :name and :title files will bind to the…
Ant
  • 747
  • 1
  • 8
  • 19
36
votes
4 answers

Setting a startup page in Blazor

The startup page in my Blazor application is Index.cshtml. I'd like to change the startup page to the homepage, namely my Home.cshtml. I'm using vs2019, ASPNET CORE Blazor (0.9.0-preview3-19154-020). Blazor Serverside has routing in the…
PeteBal
  • 361
  • 1
  • 3
  • 3
36
votes
4 answers

How to navigate to other page in angular 6?

Im trying to redirect my page from login to another page. Im following this code. My login component ts file: import { Router } from '@angular/router'; constructor(private router: Router) { } funLogin(mobilenumber){ …
sasi
  • 836
  • 4
  • 17
  • 33
36
votes
4 answers

Rails 3 - Restricting formats for action in resource routes

I have a resource defined in my routes. resources :categories And I have the following in my Category controller: def show @category = Category.find(params[:id]) respond_to do |format| format.json { render :json => @category } …
Mike
  • 16,690
  • 2
  • 19
  • 25
36
votes
2 answers

How do you use anchors for IDs in routes in Rails 3?

Imagine a blog with posts and comments. An individual comment's URL might be posts/741/comments/1220. However, I'd like to make the URL posts/741#1220, or even posts/741#comment-1230. What's the least intrusive way of doing this, so that redirect_to…
ClosureCowboy
  • 20,825
  • 13
  • 57
  • 71
36
votes
4 answers

Angular2 Routing. The requested path contains undefined segment at index 1

I have a issue with routing in Angular 2. I call router.navigate from an action into a datatable. The rare is that sometimes when i click the button that calls this line its works fine and sometimes it doesnt. this.router.navigate(['edit', id],…
Matias graña
  • 417
  • 1
  • 4
  • 11
36
votes
2 answers

Render controller action from another controller

I think the code is more explicit option A class RedirectController < ApplicationController def index redirect_to :controller => 'posts', :action => 'show', :id => 1 # it works end end option B class RedirectController <…
user142913
  • 883
  • 1
  • 7
  • 14
36
votes
4 answers

Rails' routes: how to pass "all" request params in a redirect

I want to redirect all root requests to a /pages/home url, but I want to keep all the params used in the original…
fguillen
  • 36,125
  • 23
  • 149
  • 210
36
votes
1 answer

Rails routing - :on => :collection

The Rails routing guide doesn't specify what :on => :collection means. I cannot find an explanation to what the :on key is, nor what a :collection is in that context.
Nick Ginanto
  • 31,090
  • 47
  • 134
  • 244
36
votes
10 answers

AngularJS: Change hash and route without completely reloading controller

I have a controller, with a route like this: #/articles/1234 I want to change the route without completely reloading the controller, so I can keep the position of other stuff in the controller constant (lists that scroll) I can think of a few ways…
doubledriscoll
  • 1,179
  • 3
  • 12
  • 21
35
votes
5 answers

Calling Express Route internally from inside NodeJS

I have an ExpressJS routing for my API and I want to call it from within NodeJS var api = require('./routes/api') app.use('/api', api); and inside my ./routes/api.js file var express = require('express'); var router =…
FrickeFresh
  • 1,688
  • 1
  • 19
  • 31
35
votes
5 answers

Devise logged in root route rails 3

Heyya guys. So i thought about this coolio idea, if you are logged in then you get some sort of dashboard, else you get an information/login/sign up page.. So how do i do that.. I mostly wants to do this in Routes = not something like def index …
Oluf Nielsen
  • 769
  • 1
  • 8
  • 24
35
votes
3 answers

Change default route in docker container

I have a docker container that is connected to two networks, the default bridge and a custom bridge. Via the default, it is linked to another container only in the default network and via the custom bridge, it gets an IP address in local…
martin
  • 3,149
  • 1
  • 24
  • 35
35
votes
8 answers

Accessing rails routes in javascript

Can anyone explain how i can access the rails routes/names routes in javascript ? The following are some of the things i tried http://github.com/jsierles/js_named_routes. but no luck.
kishore
  • 421
  • 1
  • 5
  • 5
35
votes
4 answers

how do return the $state.current.name from ui-router statechange

I would like to return the .state('name') when I change location in angular. From my run() it can return the $state object: .run(function($rootScope, Analytics, $location, $stateParams, $state) { console.log($state); but when I try to…
Armeen Moon
  • 18,061
  • 35
  • 120
  • 233