Questions tagged [custom-routes]

198 questions
44
votes
4 answers

rails singular resource still plural?

I have a search route which I would like to make singular but when I specify a singular route it still makes plural controller routes, is this how it's supposed to be? resource :search Gives me search POST /search(.:format) …
holden
  • 13,471
  • 22
  • 98
  • 160
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
17
votes
2 answers

resource routes to be mapped to a custom path in rails 4

I have a route like: resources :products Now I have all my code is in place but just need to change the paths from /products/:action to /items/:action I have already skimmed through the rails docs but could not figure this out. It looks very basic…
whizcreed
  • 2,700
  • 3
  • 22
  • 35
15
votes
1 answer

why no path names for custom routes in Rails

In my rails app following in routes.rb resources :users leads to following output for 'rake routes' users GET /users(.:format) users#index POST /users(.:format) users#create new_user …
Akhil
  • 6,667
  • 4
  • 31
  • 61
8
votes
1 answer

Multiple levels in MVC custom routing

I am trying to build my own little cms. I created an abstract pageBase class that is inherited by Static, Reviews, Articles, News. Each having there own controller methods. My problem is that I need to allow the admin to define his own custom path…
7
votes
1 answer

Slim3 optional parameter with controller method as callback

I have route: $app->get('/admin/login/{status}', 'App\Controller\Admin\AdminController:loginAction') How do I make {status} parameter optional?
Michal
  • 4,952
  • 8
  • 30
  • 63
6
votes
2 answers

polymorphic_path for custom collection route

I have the following route definition: resources :documents do collection do post :filter end end and the following model structure: class Document < ActiveRecord::Base belongs_to :documentable, :polymorphic => true end class User <…
6
votes
2 answers

rails routing aliases

I have a model called Spaces which has different types of places... such as Bars, Restaurants, etc. It has the same columns, same, model, controller, etc. no fancy STI, I just have one field called Space_type which I would like to determine an…
holden
  • 13,471
  • 22
  • 98
  • 160
5
votes
1 answer

Rails 3 Custom Route that takes multiple ids as a parameter

How do I add a route to my Rails 3 app which allows me to have a URL that maps to an action in a RESTful resource that accepts multiple parameters: /modelname/compare/1234,2938,40395 And then in my controller, I want to access these ids: @modelname…
Avishai
  • 4,512
  • 4
  • 41
  • 67
5
votes
1 answer

Replacing default routes for a resource in Rails 3

I have a resource defined like so: resources :referrals, :except => [:show, :edit, :destroy] and I'd like to replace (not just add a named route) a default route that Rails produces, specifically the one for the update action. Here is my rake…
Bodhi
  • 1,437
  • 1
  • 13
  • 21
5
votes
2 answers

Creating SEO friendly URLs in Rails 3

I currently have URLs which look like this: things?category_id=6&country_id=17 and I would like to have URLs which look like this: /printer_cartridges/united_kingdom Is there a way in Rails 3, without hard coding all of the categories and…
Gav
  • 11,062
  • 7
  • 33
  • 35
5
votes
1 answer

ASP.NET MVC Routes: How to define custom route

I've looked online for an answer to this question, but I honestly can't seem to find a good reference for MVC routes. I have a UserController for my User objects. One can Edit, Save, View, etc. on the User, so I have actions in that controller to…
Matt
  • 23,363
  • 39
  • 111
  • 152
4
votes
2 answers

Rails 3 Routing: Using 2 dynamic segments in path for one model

What I am trying to achieve is something similar to Github's way for routes. E.g. I have a project with the name 'question' results in the URL /hjuskewycz/question. So my goal is to have routes where the first segment is the username and the second…
hjuskewycz
  • 1,437
  • 1
  • 14
  • 20
4
votes
3 answers

ASP.NET MVC2 Route Constraint - optional number id parameter

I have a default route set up in my ASP.NET MVC2 project and would like to add/modify it for some of my other controllers. Lets say I have a Customer controller with Details action that expects and "id" parameter (int). For example: // //…
zam6ak
  • 7,229
  • 11
  • 46
  • 84
4
votes
1 answer

HttpHandler and Routes in ASP.NET MVC

In a project I'm working, I've wrote an HttpHandler to bring as response an image instead of a View, like that: using System; using System.Web; using System.Web.Routing; using MyProject.Data; using MyProject.Infrastructure; namespace…
Leonel Sanches da Silva
  • 6,972
  • 9
  • 46
  • 66
1
2 3
13 14