I''m following the tutorial here: http://edgeguides.rubyonrails.org/getting_started.html And, so far, I have the following in the routes.rb file: get "home/index" resources :posts root :to => "home#index" I know what "root :to => "home#index" is. But, what is the use of the following, what do they mean? get "home/index" resources :posts Thanks. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
run rake routes and you''ll see all the routes they create. comment one out and run it again to see what goes away -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Tony Primerano wrote:> run > > rake routes > > and you''ll see all the routes they create. comment one out and run it > again to see what goes awayThanks Tony. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hello All, In routes.rb, to create and access a new page everytime i need to write :page_name => :any to my config/routes.rb. Can you guys tell me any better alternative to this? Thanks in advance. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 17 Aug 2010, at 11:00, Hemant Bhargava wrote:> In routes.rb, to create and access a new page everytime i need to write > :page_name => :any to my config/routes.rb. > Can you guys tell me any better alternative to this?I''m not 100% sure I understoon what you''re after but take a look at: http://guides.rubyonrails.org/routing.html. Specifically section 4.9 on route globbing. or http://edgeguides.rubyonrails.org/routing.html. Section 3.10. Cheers, Jim -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hemant Bhargava wrote:> > In routes.rb, to create and access a new page everytime i need to write > :page_name => :any to my config/routes.rb.Why? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Ar Chron wrote:> Hemant Bhargava wrote: >> >> In routes.rb, to create and access a new page everytime i need to write >> :page_name => :any to my config/routes.rb.Ok. Here is the whole scenario for those who did''nt get it. I am using scaffolding type for resumes, portals, agencies etc etc. For portals and agencies i just defined map.resources :portals, :agencies and all seems to work fine. I also have map.resources for resumes. Now my question is that if i add a new page(lets say create_forward) i need to describe it like this in routes.rb, map.resources :resumes, :collection => { :create_forward } and if i add a new page (create_req) then i need to define it in routes.rb as, map.resources :resumes, :collection => { :create_req } Hope you people got it right.. :)> > Why?-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 17 August 2010 14:48, Hemant Bhargava <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Ar Chron wrote: >> Hemant Bhargava wrote: >>> >>> In routes.rb, to create and access a new page everytime i need to write >>> :page_name => :any to my config/routes.rb. > > Ok. Here is the whole scenario for those who did''nt get it. I am using > scaffolding type for resumes, portals, agencies etc etc. For portals and > agencies i just defined map.resources :portals, :agencies and all seems > to work fine. > > I also have map.resources for resumes. Now my question is that if i add > a new page(lets say create_forward) i need to describe it like this in > routes.rb, > > map.resources :resumes, :collection => { :create_forward } > > and if i add a new page (create_req) then i need to define it in > routes.rb as, > > map.resources :resumes, :collection => { :create_req } > > Hope you people got it right.. :)So are you asking the question is there a better way do define the route for create_req rather than specifying it as you have above? I don''t see how it could be much more concise. Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
Hemant Bhargava wrote:> I also have map.resources for resumes. Now my question is that if i add > a new page(lets say create_forward) i need to describe it like this in > routes.rb, > > map.resources :resumes, :collection => { :create_forward } > > and if i add a new page (create_req) then i need to define it in > routes.rb as, > > map.resources :resumes, :collection => { :create_req } >Oh, so each time you want Rails to respond to a new method for either the collection, or a member of the collection you have to specify those additional methods in your routes.rb file? Well, yes, that''s all part of using restful routing in Rails. In terms of clarity and ease of maintenance, I haven''t found a better way. You could go backwards and use non-restful routing, but that''s actually more work, or you rely on default routes (yuck) to try and match-up routes to controllers, actions and ids. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law wrote:> On 17 August 2010 14:48, Hemant Bhargava <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> >> >> Hope you people got it right.. :) > > So are you asking the question is there a better way do define the > route for create_req rather than specifying it as you have above? I > don''t see how it could be much more concise.Yeah i asked for the better way because i have created so many pages. So for each page i have to write it as above. I mean suppose i create 10 pages then each time i have to write as: map.resources :resumes, :collection => { :create_req => :any, :page1 => :any, :page2 => :any, ................... ................... :page10 => :any } So the lines of code becomes large and messy as well. Is''nt there a single/two liner for this?> > Colin-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hemant Bhargava wrote:> Colin Law wrote: >> On 17 August 2010 14:48, Hemant Bhargava <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>> >>> >>> Hope you people got it right.. :) >> >> So are you asking the question is there a better way do define the >> route for create_req rather than specifying it as you have above? I >> don''t see how it could be much more concise. > > Yeah i asked for the better way because i have created so many pages. So > for each page i have to write it as above. I mean suppose i create 10 > pages then each time i have to write as: > > map.resources :resumes, :collection => { :create_req => :any, > :page1 => :any, > :page2 => :any, > ................... > ................... > :page10 => :any } > So the lines of code becomes large and messy as well. Is''nt there a > single/two liner for this?Sort of. You probably don''t want to use RESTful routing for this. Instead, you probably want something like map.connect ''resumes/:page'', :controller => ''resumes'', :action => ''some_action'' ...and then look at params[:page] in the controller.> > >> >> ColinBest, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.