Forum: Ruby on Rails map.resources route generation: :format and variables

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.
87fdabec748d7d2e11443671c20c6014?d=identicon&s=25 Peter Harkins (Guest)
on 2007-04-14 04:48
(Received via mailing list)
In my config/routes.rb I have:
map.resources :discussions

But I can't generate proper URLs:

discussions_path(:format => :xml) -> /discussions?format=xml instead
of /discussions.xml

discussion_path(discussion, :format => :xml) -> "You have a nil object
when you didn't expect it! The error occurred while evaluating

discussion_path(discussion, :format => :xml) -> /discussions/1?
format=xml instead of /discussions/1.xml

What gives here? Am I calling the route generation wrong? Is there
something I need to add to my routes? Can anyone give me an example of
how to generate the urls correctly?
F5d61a3c93217e393cfdf7bf5c7ac628?d=identicon&s=25 Michael D. Ivey (Guest)
on 2007-04-14 04:55
(Received via mailing list)
> discussions_path(:format => :xml) -> /discussions?format=xml instead
> of /discussions.xml

Try formatted_discussions_path(:xml), etc.
87fdabec748d7d2e11443671c20c6014?d=identicon&s=25 Peter Harkins (Guest)
on 2007-04-14 05:05
(Received via mailing list)
On Apr 13, 9:54 pm, "Michael D. Ivey" <> wrote:
> Try formatted_discussions_path(:xml), etc.

Thanks, that solved it:

formatted_discussions_path(:format => :xml, 'foo' => 'bar') -> /
formatted_discussion_path(:id => @discussions.first, :format => :xml,
'foo' => 'bar') -> /discussions/1.xml?foo=bar
This topic is locked and can not be replied to.