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
29
votes
2 answers

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 know how you can get the current route name by…
brunomayerc
  • 295
  • 1
  • 3
  • 8
29
votes
1 answer

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 parameter (like in rails 2.3.5 with :id => 3). I know I…
JohnDel
  • 2,092
  • 8
  • 35
  • 64
29
votes
8 answers

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 correctly, I want to redirect to that view, with this…
Bellots
  • 1,703
  • 3
  • 19
  • 29
29
votes
1 answer

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. Angular: For instance, if I define a route in…
Lars Holdgaard
  • 9,496
  • 26
  • 102
  • 182
29
votes
10 answers

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. in…
Angelo Giuffredi
  • 923
  • 3
  • 13
  • 26
29
votes
4 answers

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 => :posts If this is not the default behavior, can it be…
knoopx
  • 17,089
  • 7
  • 36
  • 41
28
votes
4 answers

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 behavior accurately. Can I just flush route table to…
jay
  • 1,032
  • 2
  • 13
  • 20
28
votes
7 answers

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 virtual directory and converted into a…
Vinicius Ottoni
  • 4,631
  • 9
  • 42
  • 64
28
votes
1 answer

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 index view. I immediately assumed I could add other…
Gabriel Bauman
  • 2,270
  • 1
  • 22
  • 36
28
votes
1 answer

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 to default the value of direction to next.
Zahid
  • 1,822
  • 4
  • 18
  • 26
28
votes
5 answers

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
  • 1,121
  • 3
  • 12
  • 29
28
votes
3 answers

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 is because of {fruits} but I do not how solve…
Shokouh Dareshiri
  • 826
  • 1
  • 12
  • 24
28
votes
2 answers

MVC 3 Subdomain Routing

Possible Duplicate: Is it possible to make an ASP.NET MVC route based on a subdomain? In asp.net MVC 3 site i'd like to create online stores for users. Any store that is created by user should have a URL like "shopname.mydomain.com". I tried some…
Bahtiyar Özdere
  • 543
  • 1
  • 7
  • 11
28
votes
2 answers

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 using a static match statement Looking around the…
Diogo
  • 283
  • 1
  • 3
  • 4
28
votes
4 answers

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 :account_groups Is there anyway to tell rake…
spinlock
  • 3,737
  • 4
  • 35
  • 46