routes

map.resource and naming convention for singleton

Hello, I am relatively new to ruby on rails, so this question might be easy. Rails does a lot of magic and I am not sure where to look up such things, because I don't know which part of the framework is to blame. I basically did the authlogic_example and fiddled around with the code afterwards. My routes.rb looks like this map.root ...

MVC 2 AreaRegistration Routes Order

I noticed that in MVC 2 Preview 2, AreaRegistration is loading the routes for each area in an arbitrary order. Is there a good way to get one before the other? For example, I have two areas - "Site" and "Admin". Both have a "Blog" controller. I would like the following: /admin/ --> go to Admin's Blog controller / --> go to Site...

routing urls and paths in rails

I have a controller which has a method called history class UsersController < ApplicationController def history User.return_history(params[:id]) end end I have the following in my routes.rb file map.resources :users, :shallow => true do |user| user.resources :friends, :shallow => false user.resources :posts, :colle...

Session Fixation in ASP.Net MVC

Is it possible to block an action to be executed directly from the browser, but still be able to redirect to it from inside the site? I know it sounds stupid but this is what I want: Lets say there are two routes, Index and Index2 of HomeController. www.website.com/home will cause Index to be executed, I then want to execute some code...

How can I do this ASP.NET MVC 1.0 code in MVC 2.0 ?

Hi folks, I'm converting one of our ASP.NET MVC application from 1.0 to 2.0. This is code that is erroring :- string virtualPath = HttpContext.Request.ServerName() + RouteTable.Routes.GetVirtualPath( new RequestContext(HttpContext, RouteTable.Routes.GetRouteData(HttpContext)), ExpressionHelper.GetRoute...

Rails routing with date and has many

I've got the following setup: map.resources :articles map.resources :users, :has_many => [:articles] Which is fine as I can do /users/2/articles to get a list of articles by a given user. I also have a route setup to do: map.connect 'articles/month/:month/:year', :controller => 'articles', :action => 'index' Which works for find...

Is it possible to have file-system-like routes with acts_as_tree?

I have a Folder model which acts_as_tree. Is it possible that the routes represent the folder structure? Folders: 1: Folder A 2: Folder B 3: Folder C 4: Folder D 5: Folder E Routes: /folders/1 /folders/1/2 /folders/1/3/4 /folders/1/2/new /folders/... Is this possible? ...

ASP.NET MVC - Localization route

Hi, i'd like to create localized URL's for my site. They should obviously point to the same controller actions, but I want the first routevalues to -always- be the location/language specification. Is this possible? http://www.website.com/en/us/controller/action http://www.website.com/en/gb/controller/action I understand it ca...

How to use asp.net MVC routes to create Twitter style homepage

I'm trying to create twitter.com/rob to go to a dynamic page (using account/viewuser) as well as allowing twitter.com/help to go to a help page (help/index). The below code doesn't work in either order because the Default route handler always picks up ID as controller because controller/action/id are all optional. Is there any way to d...

Removing white space of urls with - in cakephp routing?

I have a URL like http://abc.com/users/index/University of Kansas and i want to make it University-of-Kansas. How is it possible via mysql using Cakephp ??? ...

Asp.Net MVC wrong URL being generated by Url.Action!

Hello Everyone, I search and read all the questions i could find here and in google, and I can't seem to find the answer! The Rout in questions is this: routes.MapRoute("Admin - Change Password", "Admin/ResetPassword/{UserId}", New With {.controller = "Admin", .action = "ResetPassword", .UserId = ""}) The Url It Generates is: /Admin...

Url.Action and routeValues inheritance

Suppose I have the following route. routes.MapRoute("SomeRouteName" , "{node}/{action}/{destination}" , new { Controller = "Document"} , new { Action = "Transfer|Destine|Remove" } ); When "/X/Destine/Y" URL is entered, the "Destine" action fires and renders a view, which contains the following: <%= Url.Action("Transfer") ...

How to use rspec to test named routes?

Hi there, Given I have a named route: map.some_route '/some_routes/:id', :controller => 'some', :action => 'other' How do I use the routing spec file 'spec/routing/some_routing_spec.rb' to test for that named route? I've tried this after the "describe SomeRouteController" block and it doesn't work, I get 'undefined method "helper": ...

Named Routes & link_to problem

I have the following routes set up: map.people 'people(.:format)', :conditions => { :method => :get }, :controller=>"people", :action=>"index" map.connect 'people(.:format)', :conditions => { :method => :post }, :controller=>"people", :action=>"create" map.new_person 'people/new(.:format)', :conditions => { :method => :get }, :controlle...

Trouble redirecting string[]

I have a form that posts several like named elements to an action like so: <%= Html.TextBox("foo") %> <%= Html.TextBox("foo") %> <%= Html.TextBox("foo") %> posts to and returns: public ActionResult GetValues(string[] foo) { //code return RedirectToAction("Results", new { foo = foo }) } the "Results" action then looks like ...

Rails RESTful Routes: override params[:id] or params[:model_id] defaults

Hello, I'm trying to understand how to change this rule directly on the map.resources: supposing I have a route: map.resource :user, :as => ':user', :shallow => true do |user| user.resources :docs, :shallow => true do |file| file.resources :specs end end so I would have RESTful routes like this: /:user/docs /docs/:i...

CakePHP and admin routing with a 'catch all' action.

I'm trying to build a mini cms, whereby all urls go to the index action of a 'products' controller. The products_controller checks the url and treats it as a parameter, so '/widgets' would hit the index($url) function and pass 'widgets' to be the $url param. I then do a lookup like this checking a field called url: $product= $this->Pr...

Rails: Proxy Pass??

I've got a web-app that I want to migrate to Rails, which is currently just plain HTML with an Apache proxy to another server, running a custom database/webserver that serves the site's dynamic content. For the moment, I want to do a staged move, since the content on the proxied server I won't be able to update until I update the static...

rails url rewriting

Hi, I have a controller person with an action searchPerson which takes a name as parameter and redirects to the person details if it founds the person else it renders the searchPerson.html.erb with an error message. I would like to always have http://localhost/person instead of http://localhost/person/searchPerson so I added a route ...

Can someone please explain to me in clear, layman's terms what the deal is with mapped resources and named routes in Ruby on Rails?

I've been using Ruby for the first time on a project at my work, so I am still somewhat learning the ropes (and loving every minute of it). While I understand the point of the map.connect functions in the route.rb file, I don't understand the "resources" and "named route" features of Rails. I have my Rails book here and read it over se...