Hi Trying to get my head around routes, particularly RESTful routes, and mapping to controllers, and the magic urls that go with them. I have a model called course_materials which acts_as_tree which also belongs_to a model called course. I have this in routes.rb map.resources :courses do |course| course.resources :course_materials do |course_material| course_materials.resources :course_materials end end in views/course_materials/new.rhtml I have a form with: url => course_material_path This generates the html I would imagine it should. e.g. action="./courses/10/course_materials/67/course_materials" However, when the form is submitted, instead of the controller maping this to ''create'' it maps it to ''update''. Could someone help me grasp why this isnt mapping to create, and what I might need to do so? is what Im trying to do even possible with restful routes? thanks Glenn --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Are you _really_ trying to nest a resource [:course_materials] within itself?? I think [and I''m just guessing here] the confusion is arising from just that. When you''ve got an id with that first :course_materials, Rails is going to send that as an update [since it has an id and therefore a record already]. I dunno if it''s possible or not to use acts_as_tree with RESTful routes but it seems like the problem lies in it. RSL On 2/10/07, glenn <glenn-H7U4i/pZ250d9SLi6J12ItHuzzzSOjJt@public.gmane.org> wrote:> > > Hi > > Trying to get my head around routes, particularly RESTful routes, and > mapping to controllers, and the magic urls that go with them. > > I have a model called course_materials which acts_as_tree which also > belongs_to a model called course. > > I have this in routes.rb > > map.resources :courses do |course| > course.resources :course_materials do |course_material| > course_materials.resources :course_materials > end > end > > in views/course_materials/new.rhtml I have a form with: > url => course_material_path > > This generates the html I would imagine it should. e.g. > > action="./courses/10/course_materials/67/course_materials" > > However, when the form is submitted, instead of the controller maping > this to ''create'' it maps it to ''update''. > > Could someone help me grasp why this isnt mapping to create, and what > I might need to do so? is what Im trying to do even possible with > restful routes? > > thanks > > Glenn > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 Feb 11, 1:36 am, "Russell Norris" <sco...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Are you _really_ trying to nest a resource [:course_materials] within > itself?? I think [and I''m just guessing here] the confusion is arising from > just that. When you''ve got an id with that first :course_materials, Rails is > going to send that as an update [since it has an id and therefore a record > already]. I dunno if it''s possible or not to use acts_as_tree with RESTful > routes but it seems like the problem lies in it. >hmm... yep - i am trying that - only because it _should_ be possible. and it kinda works - more than i dared hope... it seems that with say: /course/5/course_material/1/course_material/2 1 gets assigned to :course_material_id (which I can use for the parent) and 2 gets assigned to the id. the first problem lies matching to correct action - it seems that sometimes the left hand end gets used to match, and sometimes the right the second problem lies in being able to predict control what url helpers will do and are available the 3rd problem exists in that - you cant recurse - afaict - the extent to which you''re prepared to nest, is the extent to which you can get some results i''ve got around it by doing map.control for somethings and letting rest works where it seems to - its a bit flakey possibly, but works to a point - but inspite of getting around it - id still like to understand either how to make it work or why it doesnt thanks russell glenn> RSL > > On 2/10/07, glenn <g...-H7U4i/pZ250d9SLi6J12ItHuzzzSOjJt@public.gmane.org> wrote: > > > > > Hi > > > Trying to get my head around routes, particularly RESTful routes, and > > mapping to controllers, and the magic urls that go with them. > > > I have a model called course_materials which acts_as_tree which also > > belongs_to a model called course. > > > I have this in routes.rb > > > map.resources :courses do |course| > > course.resources :course_materials do |course_material| > > course_materials.resources :course_materials > > end > > end > > > in views/course_materials/new.rhtml I have a form with: > > url => course_material_path > > > This generates the html I would imagine it should. e.g. > > > action="./courses/10/course_materials/67/course_materials" > > > However, when the form is submitted, instead of the controller maping > > this to ''create'' it maps it to ''update''. > > > Could someone help me grasp why this isnt mapping to create, and what > > I might need to do so? is what Im trying to do even possible with > > restful routes? > > > thanks > > > Glenn--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
If it works... Work it! RSL On 2/10/07, glenn <glenn-H7U4i/pZ250d9SLi6J12ItHuzzzSOjJt@public.gmane.org> wrote:> > > > > On Feb 11, 1:36 am, "Russell Norris" <sco...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Are you _really_ trying to nest a resource [:course_materials] within > > itself?? I think [and I''m just guessing here] the confusion is arising > from > > just that. When you''ve got an id with that first :course_materials, > Rails is > > going to send that as an update [since it has an id and therefore a > record > > already]. I dunno if it''s possible or not to use acts_as_tree with > RESTful > > routes but it seems like the problem lies in it. > > > hmm... yep - i am trying that - only because it _should_ be possible. > and it kinda works - more than i dared hope... > it seems that with say: > > /course/5/course_material/1/course_material/2 > > 1 gets assigned to :course_material_id (which I can use for the > parent) > and 2 gets assigned to the id. > > the first problem lies matching to correct action - it seems that > sometimes the left hand end gets used to match, and sometimes the > right > > the second problem lies in being able to predict control what url > helpers will do and are available > > the 3rd problem exists in that - you cant recurse - afaict - the > extent to which you''re prepared to nest, is the extent to which you > can get some results > > i''ve got around it by doing map.control for somethings and letting > rest works where it seems to - its a bit flakey possibly, but works to > a point - but inspite of getting around it - id still like to > understand either how to make it work or why it doesnt > > thanks russell > glenn > > > > RSL > > > > On 2/10/07, glenn <g...-H7U4i/pZ250d9SLi6J12ItHuzzzSOjJt@public.gmane.org> wrote: > > > > > > > > > Hi > > > > > Trying to get my head around routes, particularly RESTful routes, and > > > mapping to controllers, and the magic urls that go with them. > > > > > I have a model called course_materials which acts_as_tree which also > > > belongs_to a model called course. > > > > > I have this in routes.rb > > > > > map.resources :courses do |course| > > > course.resources :course_materials do |course_material| > > > course_materials.resources :course_materials > > > end > > > end > > > > > in views/course_materials/new.rhtml I have a form with: > > > url => course_material_path > > > > > This generates the html I would imagine it should. e.g. > > > > > action="./courses/10/course_materials/67/course_materials" > > > > > However, when the form is submitted, instead of the controller maping > > > this to ''create'' it maps it to ''update''. > > > > > Could someone help me grasp why this isnt mapping to create, and what > > > I might need to do so? is what Im trying to do even possible with > > > restful routes? > > > > > thanks > > > > > Glenn > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---