Forgive me if this has been answered, I looked through the archives and didn''t see anything similar to what I was looking for. The question relates to the handling of has_many and belong_to relationship between tables. I have created a simple poll and the poll has many poll items. I can create a scaffold of both of the poll and poll items, but it doesn''t make sense to administer the poll items separately from the polls. I would have to create a poll item and manually select a poll in which it is associated. After a poll is created it would be ideal in the show action of the poll controller to be able to list all the poll items associated with the poll and have the ability to create, update and delete poll items to that particular poll. I can create custom methods in the poll class to add all the functionality of what a poll item scaffold would create, but is there a better way of handling a parent child relationship so that a you could create children under the parent scaffold? Thanks, -Derrick --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Derrick Shoemake wrote:> I can create custom methods in the poll class to add all the > functionality of what > a poll item scaffold would create, but is there a better way of > handling a parent > child relationship so that a you could create children under the > parent scaffold?you could try ajax_scaffold: http://www.ajaxscaffold.com/> Thanks, > -Derrickregards, rolando.- -- 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 -~----------~----~----~----~------~----~------~--~---
So here''s the answer you don''t want to hear, but this is the right answer. Using scaffold code doesn''t make sense for what you''re doing. You should write the UI and controller code yourself to better support what you need to do. I don''t suspect AJAX scaffold will be any better. Scaffold code isn''t something you want to use long term anyway. Just get used to not using scaffolding and you won''t be tempted to mis-apply it. (http://glu.ttono.us/articles/2006/08/30/guide-things-you-shouldnt-be-doing-in-rails) Good luck, Charlie Derrick Shoemake wrote:> Forgive me if this has been answered, I looked through the archives > and didn''t see anything similar to what I was looking for. > > The question relates to the handling of has_many and belong_to > relationship > between tables. I have created a simple poll and the poll has many > poll items. > I can create a scaffold of both of the poll and poll items, but it > doesn''t make > sense to administer the poll items separately from the polls. I > would have to > create a poll item and manually select a poll in which it is associated. > > After a poll is created it would be ideal in the show action of the > poll controller > to be able to list all the poll items associated with the poll and > have the ability > to create, update and delete poll items to that particular poll. > > I can create custom methods in the poll class to add all the > functionality of what > a poll item scaffold would create, but is there a better way of > handling a parent > child relationship so that a you could create children under the > parent scaffold? > > Thanks, > > -Derrick-- 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 -~----------~----~----~----~------~----~------~--~---
Charlie''s point is a good one. I thrashed around with scaffolding under the illusion that scaffolding wrote my application for me...it does not. I now see scaffolding is merely working code that can be referenced and in some cases, copied directly. I tried AJAX scaffolding too, and as nice as it is, it is too much of a ''black box'' experience to use directly in your own application. Charlie Hubbard wrote:> > So here''s the answer you don''t want to hear, but this is the right > answer. Using scaffold code doesn''t make sense for what you''re doing. > You should write the UI and controller code yourself to better support > what you need to do. I don''t suspect AJAX scaffold will be any better. > Scaffold code isn''t something you want to use long term anyway. Just > get used to not using scaffolding and you won''t be tempted to mis-apply > it. > > (http://glu.ttono.us/articles/2006/08/30/guide-things-you-shouldnt-be-doing-in-rails) > > Good luck, > Charlie > > Derrick Shoemake wrote: >> Forgive me if this has been answered, I looked through the archives >> and didn''t see anything similar to what I was looking for. >> >> The question relates to the handling of has_many and belong_to >> relationship >> between tables. I have created a simple poll and the poll has many >> poll items. >> I can create a scaffold of both of the poll and poll items, but it >> doesn''t make >> sense to administer the poll items separately from the polls. I >> would have to >> create a poll item and manually select a poll in which it is associated. >> >> After a poll is created it would be ideal in the show action of the >> poll controller >> to be able to list all the poll items associated with the poll and >> have the ability >> to create, update and delete poll items to that particular poll. >> >> I can create custom methods in the poll class to add all the >> functionality of what >> a poll item scaffold would create, but is there a better way of >> handling a parent >> child relationship so that a you could create children under the >> parent scaffold? >> >> Thanks, >> >> -Derrick-- 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 -~----------~----~----~----~------~----~------~--~---
Thanks everyone, I was also under the impression that the scaffold wrote all the code for me and I wasn''t doing something correctly. I am impressed with the ajax scaffold, but for starters, I really need to understand what the application is really doing. I''ve read through most of the Agile Development for Rails and found it to be very enlightening. At the same time. I''ve found a several areas that I would like to understand better, like migrations and how it helps when writing code instead of just "it''s great for versioning the database". Rails is very exciting, it''s also hard to step in with such a forward moving language and learn the simple things like find_all and find_first shouldn''t be used. (Thanks Charles!) I do think (after reading Charles blog) that a deprectated.rubyonrails.org or a dev.rubyonrails.org/deprecated would be a great addition. As newbies we could always check and see if the methods are deprecated and what is there to replace it, or if you''re like me, you would read through it first just to put it in your mind so you could recognize deprecated examples when learning and then keep up to date by reading the release notes. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---