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 nil.to_sym" 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? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Michael D. Ivey
2007-Apr-14 02:54 UTC
Re: map.resources route generation: :format and variables
> discussions_path(:format => :xml) -> /discussions?format=xml instead > of /discussions.xmlTry formatted_discussions_path(:xml), etc. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Peter Harkins
2007-Apr-14 03:05 UTC
Re: map.resources route generation: :format and variables
On Apr 13, 9:54 pm, "Michael D. Ivey" <michael.i...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Try formatted_discussions_path(:xml), etc.Thanks, that solved it: formatted_discussions_path(:format => :xml, ''foo'' => ''bar'') -> / discussions.xml?foo=bar formatted_discussion_path(:id => @discussions.first, :format => :xml, ''foo'' => ''bar'') -> /discussions/1.xml?foo=bar --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---