routes

What is the best way to route a static controller in Rails?

I have a static_controller that is in charge of all the static pages in the site and works as follows in routes.rb: map.connect ':id', :controller => 'static', :action => 'show' I have a static page called about that among other information, has a contact form. I currently have a contacts_controller that is in charge of inserting the ...

How to implement "short" nested vanity urls in rails?

I understand how to create a vanity URL in Rails in order to translate http://mysite.com/forum/1 into http://mysite.com/some-forum-name But I'd like to take it a step further and get the following working (if it is possible at all): Instead of: http://mysite.com/forum/1/board/99/thread/321 I'd like in the first step to get to someth...

What is the difference between a restful route method for getting an index vs. creating a new object?

According to rake routes, there's the same path for getting an index of objects as there is for creating a new object: cars GET /cars(.:format) {:controller=>"plugs", :what=>"car", :action=>"index"} POST /cars(.:format) {:controller=>"plugs", :what=>"car", :action=>"create"} Obviously, the HTTP verb is what distinguish...

"/#action" Route in Routes.rb in Ruby on Rails

How can I create a route of this format (in Ruby on Rails routes.rb file): /#action/id Specifically with the "#" character inserted before the action controller...for example, see http://lala.com/#album/some-album-id thanks! ...

Rails submit_to_remote can't POST

I'm trying to nest a form within another using submit_to_remote but it does a PUT instead of a POST. Can anyone explain what's wrong here? The routes are RESTful: map.resources :thing map.resources :item The view is like this: <% form_for(@thing) do |f| %> <% fields_for(Item.new) do |i| %> <%= i.text_field :name %> <%= sub...

Routing a location that matches one controller to another

Hi I have a controller named "places" with some actions like "view", "new", "create" When a user goes to mysite.com/places I want to execute the action "show" of another controller called "cores" So I've put this in the routes.rb file: map.connect '/places', :controller => "cores", :action => "show" But it doesn't work. I receive ...

will_paginate route only works on page > 1

I have the following routes defined: map.resources :categories, :has_many => :downloads map.resources :downloads, :member => {:go => :get}, :collection => {:tag => :get} map.connect '/downlods/page/:page', :controller => 'downloads', :action => 'index' map.connect '/categories/:category_id/downloads/page/:page', :controller => 'download...

Rails Nested Resources with :member

I've got something like this in my routes.rb: map.resources :retailers, :has_one => [:invite_code] map.resources :invite_codes, :member => {:redeem => :get} and it isn't generating a route that I would expect: http://localhost:3000/retailers/1/invite_code/redeem Am I doing it wrong? ...

Best Practices with MVC Route

If this is asked before just point me in the right direction I am a OO and MVC newbie. I am following along the MVC Storefront(a little outdated now) where they are talking about routes and adding them to global.asax.cs My question is this: wouldn't it be better if only 1 route is defined and after that everything is done programaticall...

Confusion about MVC Routes

What is the problem below? routes.MapRoute( "Default2", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = "test" } // Parameter defaults ); routes.MapRoute( "Default1", // Route name "{controller}/{action}/{name...

rails foobar_path(3) returnes strange path: "/foobar.3/" instead of "/foobar/3/

Hi i have this starnge behavoir... <%= link_to image_tag("image.png"), brain_path(1), :method => "put" %> produces: <a href="/brain.1" onclick="var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.met ...[many rails code]... ;return false;"><img alt="Research_4" src="/images/image.png" /...

Rails routes direct index action to show action

So I created some rspec_scaffold for an Exercise model and added "map.resource :exercises" to my routes file and I was surprised when the "/exercises" url rendered the show action. What the heck? Why doesn't that render the index action? rake routes new_exercises GET /exercises/new(.:format) {:controller=>...

rails routes for permalink with namespaced class

this one in my routes works perfectly: map.connect ':permalink', :controller => 'pages', :action => 'show' for this class: class PagesController < BackendController and on /xxx/pages it is shown like this: <%= link_to "#{item.link_name}", {:controller => :pages, :action => :show, :permalink => item.permalink} %> which will generate ...

Cakephp, Route old google search results to new home page

Hi there, I have created a new website for a company and I would like all the previous search engine results to be redirected. Since there were quite a few pages and most of them where using an id I would like to use something generic instead of re-routing all the old pages. My first thought was to do that: Router::connect('/*', ...

Problem with url_for and named routes in ActionMailer View: "Need controller and action"

I'm attempting to provide a confirmation link in my user welcome email and I'm getting the following Rails error: Need controller and action! It makes a fuss about this line: <p>Please take a moment to activate your account by going to: <%= link_to confirm_user_url(:id => @user.confirmation_code) %>.</p> In my development.rb envir...

Add the path _vti_bin/Lists.asmx to an ASP.NET MVC 2 web application

I am trying to add the path /_vti_bin/Lists.asmx to my ASP.NET MVC 2 web application. I am registering the route as follows: routes.IgnoreRoute("{resource}.asmx/{*pathInfo}"); routes.Add(new Route("_vti_bin/Lists.asmx", new ListsHandler())); where ListHandler is defined as: public sealed class ListsHandler : IRouteHandler { #reg...

Rails route hanging

I'm trying to get someone else's app up and running on my development laptop but I ran into a routing issue and I'm not sure how to debug it. For a particular controller/action, it just hangs and doesn't time out and there is no error message in the development log. Does anyone know how I can debug this? Thanks. Edited per comments. co...

Two parameters in asp.net mvc route

Hi. This is a modification to a question I've asked before on this forum. My controller action: public ActionResult SearchResults(string searchTerm, int page)... My view: <%= Html.PageLinks((int)ViewData["CurrentPage"], (int)ViewData["TotalPages"], i => Url.Action("SearchResults", new { page = i }))%>... The route entries: routes...

CakePHP Routes: Messing With The MVC

So we have a real-estate-related site that has controller/action pairs like "homes/view", "realtors/edit", and so forth. From on high it has been deemed a good idea to refactor the site so that URLS are now in the format "/realtorname/homes/view/id", and perhaps also "/admin/homes/view/id" and/or "/region/..." As a mere CakePHP novice ...

MVC2 Areas and unit testing for routes

Hello, I want to test my routes in unit tests. But Areas is not working in my unit tests. Is it possible to test ASP.NET MVC 2 routes for Areas? I am using this code [SetUp] public void SetUp() { this.routes = new RouteCollection(); MvcApplication.RegisterRoutes(this.routes); } #endregion private ...