Using edge rails, latest revision. routes.rb: map.connect '':controller/:action/:id.:format'' map.connect '':controller/:action/:id'' When I enter a url such as http://localhost:3000/player/genres everything works fine, but when I enter /player/genres.xml I get a routing error. I have both a genres.rhtml and genres.rxml in my /app/views/player folder. Do I need to something different to my routes.rb configuration? This is my player_controller.rb def genres @genres = Genre.tree respond_to do |type| type.html type.xml end end>From the log:Processing ApplicationController#index (for 127.0.0.1 at 2006-12-20 16:22:38) [GET] Session ID: 0b17ff392aa5ccd353c44e641e868772 Parameters: {} ActionController::RoutingError (no route found to match "/player/genres.xml" with {:method=>:get}): /vendor/rails/actionpack/lib/action_controller/routing.rb:1263:in `recognize_path'' /vendor/rails/actionpack/lib/action_controller/routing.rb:1253:in `recognize'' /vendor/rails/railties/lib/dispatcher.rb:40:in `dispatch'' --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
danlunde wrote:> Using edge rails, latest revision. > > routes.rb: > map.connect '':controller/:action/:id.:format'' > map.connect '':controller/:action/:id'' > > When I enter a url such as http://localhost:3000/player/genres > everything works fine, but when I enter /player/genres.xml I get a > routing error. I have both a genres.rhtml and genres.rxml in my > /app/views/player folder. Do I need to something different to my > routes.rb configuration? > > This is my player_controller.rb > def genres > @genres = Genre.tree > > respond_to do |type| > type.html > type.xml > end > end > >>From the log: > Processing ApplicationController#index (for 127.0.0.1 at 2006-12-20 > 16:22:38) [GET] > Session ID: 0b17ff392aa5ccd353c44e641e868772 > Parameters: {} > > ActionController::RoutingError (no route found to match > "/player/genres.xml" with {:method=>:get}): > /vendor/rails/actionpack/lib/action_controller/routing.rb:1263:in > `recognize_path'' > /vendor/rails/actionpack/lib/action_controller/routing.rb:1253:in > `recognize'' > /vendor/rails/railties/lib/dispatcher.rb:40:in `dispatch''This: /player/genres.xml does not match this: :controller/:action/:id.:format If you want that, you have to define a route like: :controller/:action.:format See the difference? Or just use map.resources to have this all done for you. But only if you are willing to do it all in a RESTful way. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> This: > > /player/genres.xml > > does not match this: > > :controller/:action/:id.:format > > If you want that, you have to define a route like: > > :controller/:action.:format >Really? I was reading the weblog on ruby on rails and DHH left this note under the "Formats and responds_to" section (http://weblog.rubyonrails.org/2006/11/23/rails-1-2-release-candidate-1) All new applications will have one additional default route: map.connect '':controller/:action/:id.:format''. With this route installed, imagine the following example: class WeblogController < ActionController::Base def index @posts = Post.find :all respond_to do |format| format.html format.xml { render :xml => @posts.to_xml } format.rss { render :action => "feed.rxml" } end end end GET /weblog # returns HTML from browser Accept header GET /weblog.xml # returns the XML GET /weblog.rss # returns the RSS I thought that :id only matched if it is specified but will default without if necessary. I also have an index action doing /player and /player.xml, but resulting in the same problems (/player.xml gives a routing error). I am using REST for my model classes, but the player isn''t a model and doesn''t CRUD. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Dec 20, 5:08 pm, "danlunde" <danlu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > This: > > > /player/genres.xml > > > does not match this: > > > :controller/:action/:id.:format > > > If you want that, you have to define a route like: > > > :controller/:action.:format > > Really? I was reading the weblog on ruby on rails and DHH left this > note under the "Formats and responds_to" section > (http://weblog.rubyonrails.org/2006/11/23/rails-1-2-release-candidate-1) > > All new applications will have one additional default route: > map.connect '':controller/:action/:id.:format''. With this route > installed, imagine the following example: > > class WeblogController < ActionController::Base > def index > @posts = Post.find :all > respond_to do |format| > format.html > format.xml { render :xml => @posts.to_xml } > format.rss { render :action => "feed.rxml" } > end > end > end > GET /weblog # returns HTML from browser Accept header > GET /weblog.xml # returns the XML > GET /weblog.rss # returns the RSS > > I thought that :id only matched if it is specified but will default > without if necessary. I also have an index action doing /player and > /player.xml, but resulting in the same problems (/player.xml gives a > routing error). I am using REST for my model classes, but the player > isn''t a model and doesn''t CRUD.Since I have two actions in the player_controller index and genres, what route would I need to satisfy both /player.xml and /player/genres.xml as well as /player and /player/genres? It seems that by using map.connect ":controller/:action.:format" I can do /player/genres.xml but not /player.xml, though /player/index.xml seems to work. It would seem like map.connect '':controller/:action/:id.:format'' would be correct, but it doesn''t seem to work. Shouldn''t the defaults => { :action => "index", :id => nil } be used in the absence of :action or :id? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---