Questions tagged [custom-routes]

203 questions
4
votes
1 answer

Creating custom routes where a model attribute is used instead of the ID in Rails

I have a model called Student, which has an attribute called University_ID in it. I created a custom action and route which displays the details of a specific student via the following link :students/2/detailsi.e. students/:id/details However, I…
3
votes
1 answer

RSpec tests for custom username routes are failing

I have a constrained route that matches usernames like this: controller :users, :path => '/:username', :as => :user, :constrain => { :username => /^_?[a-z]_?(?:[a-z0-9]_?)*$/i } do # lots of nested routes go here end When I go to write RSpec…
ZeNewb
  • 435
  • 5
  • 16
3
votes
1 answer

Rails Routing Precedence favors the first

So Ive been working on a rails project that defines two different create actions in the same controller. Here's my controller: class SmsSendsController < ApplicationController def new @at = SmsSend.new @contact = Contact.find_by(id:…
3
votes
0 answers

asp.net core custom IRouter Dependency Injection

I'm creating a custom routing in asp.net core 2, where I check the path in a DB and update action and controller to the desired one. I have this custom IRouter defined like this public interface IRouteCustom : IRouter { } public class RouteCustom…
3
votes
1 answer

Rails3 custom controller method not routed: works in Rails2

I've been using Rails 2.3.8 for a project that I've been working on, but have just migrated the project over to Rails 3.0.3. After ironing out the basic bugs, I've got a problem now with a custom controller method. In the gallery_controller, I had…
Josh Kovach
  • 7,161
  • 3
  • 45
  • 59
3
votes
0 answers

Web API 2 Route Attribute not working?

OK I have spent all day looking over this code and cannot figure out what I have done wrong. This is Web API 2 on .NET 4.5.2 Here is my Global.asax.cs public class WebApiApplication : HttpApplication { protected void Application_Start() { …
Jason H
  • 4,476
  • 5
  • 23
  • 39
3
votes
2 answers

Render a 'micropost feed' from the Rails Tutorial in a custom location/view?

I followed Michael Hartl's 'Rails Tutorial' book and need to render the 'micropost feed' at a custom location (/members) instead of at the site's root. I've updated the SessionsController so that when a user logs in they are redirected to the new…
CryptoPiggy
  • 680
  • 2
  • 8
  • 21
3
votes
1 answer

AngularJS - ui.router - How to redirect to the needed state after adding them dynamicaly?

I'm trying to add states dynamicaly to my app following the answer of that question : AngularJS - UI-router - How to configure dynamic views app.run(['$q', '$rootScope', '$state', '$http', function ($q, $rootScope, $state, $http) { …
Nomaki
  • 41
  • 1
  • 4
3
votes
3 answers

rails routes and custom routing for nested resource

For several projects I need something to simplify my routes to remove the controller name for one of the most important routes. In this case editions, so instead of domain.com/editions/london/venues/the-venue We use…
ere
  • 1,689
  • 1
  • 19
  • 39
3
votes
1 answer

MVC Custom Route. DataTokens["Namespaces"] is ignored

I don't know why while creating a CustomRoute which inherits from Route, the field DataTokens["Namespaces"] is ignored. And I get the error: Multiple types were found that match the controller named 'Home'. This can happen if the route that…
Cristian E.
  • 2,167
  • 3
  • 23
  • 46
3
votes
1 answer

How to force custom Rails route to use :id instead of :_id

I defined the following custom Rails route in routes.rb: resources :projects do get 'members' end This results in the following route (output from rake routes): project_members GET /projects/:project_id/members(.:format) What I would…
Andy R.
  • 199
  • 2
  • 12
3
votes
4 answers

regex to match something that is 1+ chrs, but not 500 chrs

I'm looking for a single regex expression that will match something that is 1 or more characters in length that does not match 500. This is to be used in a Rails routes file, particularly to handle exceptions. routes.rb match '/500', to:…
Brad Rice
  • 1,236
  • 2
  • 15
  • 34
3
votes
3 answers

global.asax redirecttoroute not working

I want to use a custom route in my global.asax with response.redirecttoroute but it is not working. I have the following in my RouteConfig: routes.MapRoute( name: "Error", url: "Error/{action}/{excep}", defaults:…
Jurgen Vandw
  • 631
  • 7
  • 26
2
votes
1 answer

RouteHandler for Static Content

We want to route all static content (js, css, images - png, gif, jpeg, jpg) of our application to a RouteHandler. Where we'll do Best Practices for Speeding up Web Sites. Like adding ETags, Cache Control, Expires, etc for all our static content. How…
Ramiz Uddin
  • 4,259
  • 4
  • 35
  • 71
2
votes
1 answer

Using Zend Routes? to customized url

This is getting me confused. How do I customize /state/state_name to be replaced by /state/state_name.php? Initially state_name is a variable and I don't want each of the state to be an action in my StateController. Instead, I would like to take…
ruelluna
  • 707
  • 8
  • 30
1
2
3
13 14