routes

Custom RESTful route within has_many nesting

Projects have many tasks and a task has a custom RESTful action called 'approve'. I'm expecting the helper to look something like this approve_project_task_url This isn't working for me: map.resources :projects, :has_many => :tasks, :member => { :approve => :post } ...

ASP.Net MVC Routes

Hello, I'm trying to set a simple routing system in my ASP.NET MVC C# application and it doesn't work :/ Here is my root "http://localhost/Admin/" or "http://localhost/Admin/Home.mvc/Index" I have a HomeController which manages an Index and a Start page. In the Index page, I have a list of client to select (button or whatever) and I...

Preprocessing route parameters in Python Routes

Hello Folks, I'm using Routes for doing all the URL mapping job. Here's a typical route in my application: map.routes('route', '/show/{title:[^/]+}', controller='generator', filter_=postprocess_title) Quite often I have to strip some characters (like whitespace and underscore) from the {title} parameter. Currently there's one call pe...

Problem with custom routes in Rails

I have this line in routes: map.resources :questions, :new => {:vote_for => :put, :vote_against => :put}, :has_many => :replies, :shallow => true And I use the following helpers in my view: link_to 'OK', vote_for_question_path(@question), :method => :put link_to 'NO', vote_against_question_path(@question), :method => :put But unfort...

Dealing with Alias URLs in CakePHP

I am rewriting our company website in cakephp, and need to find a way to do the following: A user enters our site by using one of the promotional alias URLS that has been pregenerated for a specific media advert ( magazine, web promotion etc ) The URL is checked against a database of alias URLs, and if an alias exists, then a specific ...

ASP.NET MVC Action Gives 404 on Certain Params?

I'm getting a strange error in my MVC site. I have an action in my controller which responds to the default route of {controller}/{action}/{id} - in my case, /Project/Client/{id}. Depending on the id I pass to it, I get an error. With Elmah off, it's a straight-up ASP.NET 404 error. Turning Elmah on gives me the following: System.Web.H...

Weird problem when Posting to an ASP.NET MVC action.

Hi folks, I've got a simple html form with a few input boxes. When i click save, it finds the correct method but the data is weird. When i have a form field name that is the same name as a field in the route, the value passed in is my form field data, not the route data. for example. Imagine u have the following route. // Both Get/Po...

Generating nested routes in a custom generator

I'm building a generator in rails that generates a frontend and admin controller then adds the routes to the routes file. I can get the frontend working with this: m.route_resources controller_file_name but I can't figure out how to do the same for the nested admin route (admin/controller_file_name). Anyone know how to generate these ...

How to translate and modify map.resources :document

map.resources :document After adding this route, I now have an automatic "edit_document_path". I wanted to change this to "annotate_document_path"? Will it automatically pick this up if I add a new view and controller method? How does it translate from the resource route to these "path" notations? ...

ASP.Net MVC: Request variables through Routes and View method

Basically if I wanted to make something a search page with paging I would need a url like: /Topics/Index?search=hi&page=1 What I can't seem to figure out is how to: A) Set a default route with no search and page 1 /Topics/Index?page=1 or even /Topics/Index?search=&page=1 B) use the View method to do the same I do see that if ...

Unit testing MVC routes that POST

I have 2 routes registered as follows: routes.MapRoute("GetAnEmail", "{controller}", new { controller = "Home", action = "GetAnEmail" }, new { httpMethod = new HttpMethodConstraint("POST") }) routes.MapRoute("Home", "{controller}/{action}", new { controller = "Home", action = "Index" }) I have a valid unit test for the Home controller...

ASP.Net MVC: So wait... The Default Route Parameter Has To Be Named id?

Has anyone else had this issue? I have to be doing something wrong. So I'm setting up a route for errors like this: routes.MapRoute ( "SharedError", "Shared/Error/{error}", new { error = "" } ); And calling like: return parentController.RedirectToRoute("SharedError", new RouteValueDictionary(new { error = errorMessage.ToString()...

No route matches "/javascripts/prototype.js" -> explicitly define one?

When I call the index action of my assets controller, the corresponding index template uses the assets layout which includes this line: <%= javascript_include_tag 'prototype' %> The error I get is: No route matches "/javascripts/prototype.js" with {:method=>:get} This is my routes file: ActionController::Routing::Routes.draw do |...

Delete URL for nested associations

Hi guys, I'm having the following many to many relationship in Rails (ActiveResource, of course): class User < ... has_many :channel_assignments has_many :channels, :through => :channel_assignments end class Channel < ... has_many :channel_assignments has_many :users :through => :channel_assignments end class ChannelAssignme...

How Rails be configured to access a media resource that is not in its conventional directory location?

Let's say I have an image that does not reside in the normal location: {appname}/public/images/unconventional.gif But instead here: {appname}/unconventional.gif I understand this is a complete violation of Rails conventions, is immoral and you should never do this under any circumstances and, furthermore, why would I even suggest s...

Does map.connect accept a wildcard-style format in the URL?

If I want to match x.gif and y.gif, is it possible to pass a URL to map.connect that encompasses the possibilities of both filenames something like this: map.connect "public/images/:name.gif", :controller => "static_image_controller", :action => "serve" And then receive the param in my StaticImageController as params[:name]? clas...

What's the best guide to Rails routes for the totally confused?

I've been learning Rails but routes continues to confuse the heck out of me. The thing that makes it most confusing, I think, is that the routes you define are sensitive to where they are defined in your routes.rb file relative to other routes. Has anyone come across a nice simple guide that sums things up well? ...

Restful Rails controller for Flex front end

So I have an existing rails app that I've been asked to retrofit to support a flex client. Since I don't really want to muck around with the existing controllers and routes, I thought the best way to accomplish this would be to create a subdirectory in app/controllers called flex and put in some additional controllers in there to handle...

Rails: Routing resources/paths with :path_prefix and :name_prefix

I have the following route definied: map.resources :addresses, :path_prefix => ':site', :name_prefix => 's_' I've had no problem correcting my scaffolding links for "Show" and "New". But I am getting a failure to generate error when attempting to use: edit_s_address_path(address) or edit_s_address rake routes shows that this is the...

Pylons/Routes rewrite POST or GET to fancy URL

The behavior I propose: A user loads up my "search" page, www.site.com/search, types their query into a form, clicks submit, and then ends up at www.site.com/search/the+query instead of www.site.com/search?q=the+query. I've gone through a lot of the Pylons documentation already and just finished reading the Routes documentation and am w...