Hello, I am new to rails. I have a table customer and another table customercontact Following is part of my tables table customer { id, name, ... } table customercontact { id, customer_id, ... } I created the models and I created the scaffolds. But when I try to add customercontact I am not getting an option to add customer_id (not even a text box). Did this happen to anyone. If so how to resolve this. Thanks Dilip -- 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 -~----------~----~----~----~------~----~------~--~---
Dilip wrote:> Hello, > I am new to rails. I have a table customer and another table > customercontact > Following is part of my tables > > table customer > { > id, > name, > ... > } > > table customercontact > { > id, > customer_id, > ... > } > > I created the models and I created the scaffolds. But when I try to add > customercontact I am not getting an option to add customer_id (not even > a text box). Did this happen to anyone. If so how to resolve this. > > Thanks > DilipHi Dilip: Scaffolding does not build the drop-downs to connect your two tables, because there''s no way for the generator to know how you intend to populate that dropdown. You''ll need to build the <select> dropdown to choose customer id yourself, using the select helper. It will look something like this: <%= select(''customercontact'',''customer_id'',Customer.find(:all).collect {|c| [c.name,c.id]}) %> I''d really recommend you get the Agile Web Development With Rails book from Pragmatic Programmer (~$22 for PDF download) and work through the tutorial. It demonstrates how to accomplish most basic functionality like this. c. -- 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 -~----------~----~----~----~------~----~------~--~---
On 11/17/06, Cayce Balara <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Scaffolding does not build the drop-downs to connect your two tables, > because there''s no way for the generator to know how you intend to > populate that dropdown.It does if you use the Scaffolding Extensions plugin [1]. I don''t recommend using it as a generator, but it works great as a class method. [1] http://wiki.rubyonrails.com/rails/pages/Scaffolding+Extensions+Plugin Jeremy --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---