named-routing

How do you insert a named route into the RouteCollection object?

I exclusively use named routes (as a best practice) when using ASP.NET Routing. The RouteCollection object has an Add function that allows you to easily add a named route to the collection. However, if you need to insert a named route (due to routing order) the Insert function does not have a name parameter and therefore it doesn't see...

quick rails named routes question

In my view I specify a named route like this: show.html.erb -> seo_path(:id => "45") Now in my routes I define like so: routes.rb -> map.seo "/pages/:id/:permalink", :controller => "pages", :action => "show" Below is the error message I am getting. Apparently the diff is the id, although I don't know why. Update: I am getting t...

Named Routes in Rails: how to capture a custom url and then send params to update

I want to have this exact named route that I can put in views: <%= link_to publish_review_path(@review) %> ... I would like it to map to a path like this: "/reviews/3456/publish" ... and then when that pattern is matched, have the following sent to the controller: { :controller => "reviews", :action => "update", :id => "3...

Using named routes with parameters and form_tag

I'm trying to create a simple search form in Rails, but I think I'm missing something. I have a named route for search: map.search ":first_name/:last_name", :controller => "home", :action => "search" I'm trying to use that in my search form: <% form_tag(search_path, :method => 'get') do %> <%= text_field_tag(:first_name) %> <%= ...

How to add :format options to a named route in Rails?

I've got a named route called profile and I would like to be able to access it as json. But when I look at my rake routes output I see that the (.:format) is missing. How do I add it to a named route? user GET /users/:id(.:format) {:action=>"show", :controller=>"users"} profile /:username {:action=>"show", :contro...

rails named routes + controller as parameter

Hi, is it possible to have the controller value in a rails named route as a parameter, which I can pass at runtime to direct the call to the proper controller? e.g. map.ride 'ride' ,:controller => {some-way-of-specifying-a-parameter}, :action => 'ride' then at runtime, I want to pass the controller name to which this call should be goi...

In Ruby on Rails, routes.rb, if map.something will create something_path and something_url, does map.connect create something like that too?

In Ruby on Rails, routes.rb, if we create a "named route" map.something ":a/:b", :controller => 'foobar' it will also create something_path and something_url which are two methods usable in the controller and in the view. Does map.connect create something like that too? Otherwise, isn't map.connect somewhat disadvantaged in this way?...

match method in routes.rb

I'm trying to follow this tutorial here but the tutorial seems to use this "match" function. match '/about', :to => 'pages#about' Whenever, I do the same, I get this error from the server: undefined method `match' for main:Object How can I edit the routes.rb file such that: it will route from a long file path to a short one ...

How do I specify that a named route should use a model's columns its _url and _path functions?

I have a Posts model with id and title columns. I've got my route (rails 2.3.8) set up as follows: map.post ':title/:id', :controller => 'posts', :action => 'show' which works correctly when recognising URLs and when generating them explicitly, as in post_url(:title => 'foo', :id => 123) which comes out nicely as /foo/123. What I...