Forum: Ruby on Rails How to do /tag/:tag/articles with map.resources correctly ?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Qw E. (Guest)
on 2007-02-18 03:48

Currently I have


  map.resources :tags do |tags|
    tags.resources :articles, :name_prefix => 'tag_'

with tag_articles_path(tag_name) it maps like I want to:


.. but if I have a tag selected. If I do, for example,
tag_articles_path(:order => 'top') and at this moment tag_id is nil, I
get this error:

tag_articles_url failed to generate from {:action=>"index",
:controller=>"articles"} - you may have ambiguous routes, or you may
need to supply additional parameters for this route.  content_url has
the following required parameters: ["tags", :tag_id, "articles"] - are
they all satisifed?

I think, this is right... But what should I do if I need to use all this

tag_new_article_path, tag_articles_path(:order => 'top'), etc ?

I know, I can write all helper methods I need or do something like

current_tag ? tag_articles_path : articles_path


articles_path(:tag => current_tag), articles_path(:tag => current_tag,
:order ..) - in this case I do not know how to get good looking urls

maybe there are a better way to handle this ?

Thank you.
This topic is locked and can not be replied to.