I am new to rails. I am trying to study the structure of rails. And I am wondering, where is the default action for all the controllers (i.e. index) defined. How does rails know that when no action is defined in URL it just loads index as the default action? I assume that this must be in some of the libraries, but anybody who could tell me where. Thanks a lot. :) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ar Chron
2008-May-09 18:03 UTC
Re: How to change the default action for all the controllers
muyayi wrote:> I am new to rails. I am trying to study the structure of rails. And > I am wondering, where is the default action for all the controllers > (i.e. index) defined. How does rails know that when no action is > defined in URL it just loads index as the default action? I assume > that this must be in some of the libraries, but anybody who could tell > me where. Thanks a lot. :)If you''re looking at RESTful rails, its just versions of GET, PUT, POST, DELETE requests: Method URL path Action Helper GET /people index people_url GET /people/1 show person_url(:id => 1) GET /people/new new new_person_url GET /people/1;edit edit edit_person_url(:id => 1) PUT /people/1 update person_url(:id => 1) POST /people create people_url DELETE /people/1 destroy person_url(:id => 1) Browsers cannot issue an http DELETE, so Rails fakes this out with a POST request with an additional hidden parameter named ''_method'' whose value is ''delete''. When Rails receives a _method parameter, it ignores the real http method, and substitutes the value of _method as the request type. I''d list the reference back to the site I poached this from if I could remember what it was. -- 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 -~----------~----~----~----~------~----~------~--~---
Ruby Freak
2008-May-11 05:17 UTC
Re: How to change the default action for all the controllers
I believe the default is set in: C:\ruby\lib\ruby\gems\1.8\gems\actionpack-2.0.2\lib\action_controller \resources.rb, but... You better really know what you are doing if you muck with this. On May 9, 11:03 am, Ar Chron <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> muyayi wrote: > > I am new to rails. I am trying to study the structure of rails. And > > I am wondering, where is thedefaultactionfor all the controllers > > (i.e.index)defined. How does rails know that when noactionis > >definedinURLitjustloadsindexas thedefaultaction? Iassume > > that this must be in some of the libraries, but anybody who could tell > > me where. Thanks a lot. :) > > If you''re looking at RESTful rails, itsjustversions of GET, PUT, POST, > DELETE requests: > > Method URLpath Action Helper > GET /people index people_url > GET /people/1 show person_url(:id => 1) > GET /people/new new new_person_url > GET /people/1;edit edit edit_person_url(:id => 1) > PUT /people/1 update person_url(:id => 1) > POST /people create people_url > DELETE /people/1 destroy person_url(:id => 1) > > Browsers cannot issue an http DELETE, so Rails fakes this out with a > POST request with an additional hidden parameter named ''_method'' whose > value is ''delete''. When Rails receives a _method parameter, it ignores > the real http method, and substitutes the value of _method as the > request type. > > I''d list the reference back to the site I poached this from if I could > remember what it was. > -- > Posted viahttp://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 -~----------~----~----~----~------~----~------~--~---
Ix Quic
2008-May-12 12:36 UTC
Re: How to change the default action for all the controllers
http://dev.rubyonrails.org/ticket/11181> change default action paths for "new" and "edit", in an environment or directly> in the route definition (because on some languages, coherent action names > would depend on the resource name):> > config.action_controller.resources_path_names = { :new => ''nuevo'', :edit => ''editar'' } > > In the route definition: > > map.resource :schools, :as => ''escuelas'', :path_names => { :new => ''nueva'' } >As for the index method, why would you want to rename this? It''s just internal.> On May 9, 11:03 am, Ar Chron <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:..>> Method URLpath Action Helper..>> GET /people/1;edit edit edit_person_url(:id => 1)This has been changed (http://dev.rubyonrails.org/changeset/6485) over a year ago. It is now GET /people/1/edit because the semicolon was a bad idea to begin with. Stuff after a semicolon isn''t recognized as part of the URL by some browsers. Unfortunately many tutorials still have this old syntax which isn''t recognized by Rails 2. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Not intending to start a war here but I thought that the semicolon was a good idea. By the http spec it is a non-breaking (ie., not introducing another level) part of the url. In that regard is was more expressive of RESTful routes because ''edit'' (from the previous post) is something that you''re doing to the instance identified on the same level; now it looks like edit is one level down from the object (that is, you''re looking for the edit object scoped to some person). The problem was that several browsers were written only to recognize semicolons in query strings, which was a subset of the appropriate/ permissible urls they could have recognized. Their implementation made perfect sense on a pragmatic level: it reflected the generally accepted use even if it was not the defined standard. Go figure... you follow the rules and you''re labeled the bad boy. Next thing you know they''ll try to implement all the defined HTTP verbs or something crazy like that. :) On May 12, 8:36 am, Ix Quic <ixquic696...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> http://dev.rubyonrails.org/ticket/11181 > > > change default action paths for "new" and "edit", in an environment or directly > > > in the route definition (because on some languages, coherent action names > > would depend on the resource name): > > > > > config.action_controller.resources_path_names = { :new => ''nuevo'', :edit => ''editar'' } > > > In the route definition: > > > map.resource :schools, :as => ''escuelas'', :path_names => { :new => ''nueva'' } > > As for the index method, why would you want to rename this? It''s just internal. > > > > > On May 9, 11:03 am, Ar Chron <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > .. > >> Method URLpath Action Helper > .. > >> GET /people/1;edit edit edit_person_url(:id => 1) > > This has been changed (http://dev.rubyonrails.org/changeset/6485) over a > year ago. It is now > > GET /people/1/edit > > because the semicolon was a bad idea to begin with. Stuff after a semicolon > isn''t recognized as part of the URL by some browsers. Unfortunately many > tutorials still have this old syntax which isn''t recognized by Rails 2.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---