I’ve got a new Rails 2.0.2 application for which I created CRUD functionality with: ruby script/generate scaffold Csv [with a few fields and their types] http://localhost:3000/csvs runs fine, invoking: app\controllers\ csvs_controller.rb (CsvsController#indexmethod) app\views\csvs\index.html.erb My goal to make http://localhost:3000 act the same way, but instead it displays: public\index.html or Routing Error No route matches "/" with {:method=>:get} if I remove the index.html file. config\routes.rb contains: ActionController::Routing::Routes.draw do |map| map.resources :csvs [snip] map.connect '':controller/:action/:id'' map.connect '':controller/:action/:id.:format'' end I thought the “map.resources” statement would accomplish my goal. Two questions: 1. What purpose does it serve? 2. How can I achieve my goal? I’ve looked at the REST online resources and a couple of books but (so far) I can’t get my head around this stuff. Thanks in Advance, Richard --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, Richard You may re-check the routes.rb again, and you will find one line just like # map.root :controller => "welcome" you can remove the "#" and replace "welcome" with any controller name you want,In your case, it should be "csvs" --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hey Richard, try map.index ''/'', :controller => ''csvs'', :action => ''index'' Rick On Dec 3, 9:04 pm, RichardOnRails <RichardDummyMailbox58...-FtJgd9dCuO3JTKoYRCtP1UEOCMrvLtNR@public.gmane.org> wrote:> I’ve got a new Rails 2.0.2 application for which I created CRUD > functionality with: > ruby script/generate scaffold Csv [with a few fields and their types] > > http://localhost:3000/csvsruns fine, invoking: > app\controllers\ csvs_controller.rb (CsvsController#indexmethod) > app\views\csvs\index.html.erb > > My goal to makehttp://localhost:3000act the same way, but instead > it displays: > public\index.html > or > Routing Error > No route matches "/" with {:method=>:get} > if I remove the index.html file. > > config\routes.rb contains: > ActionController::Routing::Routes.draw do |map| > map.resources :csvs > [snip] > map.connect '':controller/:action/:id'' > map.connect '':controller/:action/:id.:format'' > end > > I thought the “map.resources” statement would accomplish my goal. Two > questions: > 1. What purpose does it serve? > 2. How can I achieve my goal? > > I’ve looked at the REST online resources and a couple of books but (so > far) I can’t get my head around this stuff. > > Thanks in Advance, > Richard--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Guys, Just after I posted, I found (and adapted the following in The Art of Rails), which met my goal perfectly: map.home ''/'', :controller => ''csvs'', :action => ''index''> map.index ''/'', :controller => ''csvs'', :action => ''index''worked fine, too, Rick. Thanks for that> map.root :controller => "csvs"worked fine, too, Daniel. Thanks for that. Question: Is that “map.resources :csvs” at the beginning useless, or does it serve some purpose? Can I shoehorn in a related question? I want to add another link in index.html.erb. I want to RESTfully invoke load_cvs_filenames in the csvs controller. Is that simple to write? Best wishes to y''all, Richard On Dec 4, 1:12 am, Rick <Richard.T.Ll...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hey Richard, > > try > > map.index ''/'', :controller => ''csvs'', :action => ''index'' > > Rick > > On Dec 3, 9:04 pm, RichardOnRails > > <RichardDummyMailbox58...-FtJgd9dCuO3JTKoYRCtP1UEOCMrvLtNR@public.gmane.org> wrote: > > I’ve got a new Rails 2.0.2 application for which I created CRUD > > functionality with: > > ruby script/generate scaffold Csv [with a few fields and their types] > > >http://localhost:3000/csvsrunsfine, invoking: > > app\controllers\ csvs_controller.rb (CsvsController#indexmethod) > > app\views\csvs\index.html.erb > > > My goal to makehttp://localhost:3000actthe same way, but instead > > it displays: > > public\index.html > > or > > Routing Error > > No route matches "/" with {:method=>:get} > > if I remove the index.html file. > > > config\routes.rb contains: > > ActionController::Routing::Routes.draw do |map| > > map.resources :csvs > > [snip] > > map.connect '':controller/:action/:id'' > > map.connect '':controller/:action/:id.:format'' > > end > > > I thought the “map.resources” statement would accomplish my goal. Two > > questions: > > 1. What purpose does it serve? > > 2. How can I achieve my goal? > > > I’ve looked at the REST online resources and a couple of books but (so > > far) I can’t get my head around this stuff. > > > Thanks in Advance, > > Richard--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hey Richard, Long time no speak... On Dec 3, 8:51 pm, RichardOnRails <RichardDummyMailbox58...-FtJgd9dCuO3JTKoYRCtP1UEOCMrvLtNR@public.gmane.org> wrote:> Question: Is that “map.resources :csvs” at the beginning useless, or > does it serve some purpose? >Here''s where I find scaffolding most useful - it gives you a picture of how the different RoR components play together. rails -d postgresql test cd test script/generate scaffold Document title:string synopsis:string body:text author:string Now you can sniff out one way that MVC splits the processing in RoR just by perusing the newly created files built in support of your Document model. But, to your specific question: grep documents config/routes.rb ==> map.resources :documents When in doubt, rake it out... rake routes (in /Users/rick/test) documents GET /documents {:controller=>"documents", :action=>"index"} formatted_documents GET /documents.:format {:controller=>"documents", :action=>"index"} POST /documents {:controller=>"documents", :action=>"create"} POST /documents.:format {:controller=>"documents", :action=>"create"} new_document GET /documents/new {:controller=>"documents", :action=>"new"} formatted_new_document GET /documents/new.:format {:controller=>"documents", :action=>"new"} edit_document GET /documents/:id/edit {:controller=>"documents", :action=>"edit"} formatted_edit_document GET /documents/:id/edit.:format {:controller=>"documents", :action=>"edit"} document GET /documents/:id {:controller=>"documents", :action=>"show"} formatted_document GET /documents/:id.:format {:controller=>"documents", :action=>"show"} PUT /documents/:id {:controller=>"documents", :action=>"update"} PUT /documents/:id.:format {:controller=>"documents", :action=>"update"} DELETE /documents/:id {:controller=>"documents", :action=>"destroy"} DELETE /documents/:id.:format {:controller=>"documents", :action=>"destroy"} /:controller/:action/:id /:controller/:action/:id.:format map.resources :your_model_pluralized gives you many url_for and path_for routes that can be used to hook up with specific :controller :action [:id]. You''ll see examples of use in the scaffold generated controller and views.> Can I shoehorn in a related question? > > I want to add another link in index.html.erb. I want to RESTfully > invoke load_cvs_filenames in the csvs controller. Is that simple to > write? >It''s not clear to me what you''re after here. Any more thoughts? Rick --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Rick,> grep documents config/routes.rb ==> map.resources :documents > When in doubt, rake it out... > rake routesThanks for the mini-tutorial. I''ve started getting my routing spec/ usage working, so at the moment I have no outstanding questions. But wait until tomorrow :-) I just got the beginning of a PayrollApp working with - routes, - xxx_path and, shortly, - create multiple If you''re interested, checkout my routes and controller at http://www.pastie.org/340100. Best wishes, Richard On Dec 16, 4:03 pm, Rick <Richard.T.Ll...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hey Richard, > > Long time no speak... > > On Dec 3, 8:51 pm, RichardOnRails > > <RichardDummyMailbox58...-FtJgd9dCuO3JTKoYRCtP1UEOCMrvLtNR@public.gmane.org> wrote: > > Question: Is that “map.resources :csvs” at the beginning useless, or > > does it serve some purpose? > > Here''s where I find scaffolding most useful - it gives you a picture > of how the different RoR components play together. > > rails -d postgresql test > cd test > script/generate scaffold Document title:string synopsis:string > body:text author:string > > Now you can sniff out one way that MVC splits the processing in RoR > just by perusing the newly created files built in support of your > Document model. > > But, to your specific question: > > grep documents config/routes.rb ==> map.resources :documents > > When in doubt, rake it out... > > rake routes > (in /Users/rick/test) > documents GET /documents > {:controller=>"documents", :action=>"index"} > formatted_documents GET /documents.:format > {:controller=>"documents", :action=>"index"} > POST /documents > {:controller=>"documents", :action=>"create"} > POST /documents.:format > {:controller=>"documents", :action=>"create"} > new_document GET /documents/new > {:controller=>"documents", :action=>"new"} > formatted_new_document GET /documents/new.:format > {:controller=>"documents", :action=>"new"} > edit_document GET /documents/:id/edit > {:controller=>"documents", :action=>"edit"} > formatted_edit_document GET /documents/:id/edit.:format > {:controller=>"documents", :action=>"edit"} > document GET /documents/:id > {:controller=>"documents", :action=>"show"} > formatted_document GET /documents/:id.:format > {:controller=>"documents", :action=>"show"} > PUT /documents/:id > {:controller=>"documents", :action=>"update"} > PUT /documents/:id.:format > {:controller=>"documents", :action=>"update"} > DELETE /documents/:id > {:controller=>"documents", :action=>"destroy"} > DELETE /documents/:id.:format > {:controller=>"documents", :action=>"destroy"} > /:controller/:action/:id > /:controller/:action/:id.:format > > map.resources :your_model_pluralized gives you many url_for and > path_for routes that can be used to hook up with > specific :controller :action [:id]. You''ll see examples of use in the > scaffold generated controller and views. > > > Can I shoehorn in a related question? > > > I want to add another link in index.html.erb. I want to RESTfully > > invoke load_cvs_filenames in the csvs controller. Is that simple to > > write? > > It''s not clear to me what you''re after here. Any more thoughts? > > Rick--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---