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...
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...
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...
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) %>
<%= ...
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...
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 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?...
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 ...
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...