Benjamin Hecht
2006-Sep-18 23:59 UTC
Accessing data in a separate table w/out relationship
This question has two parts 1) I currently have setup two models and 1 controller. In the view of the controller I have setup a form with a select form component and would like the values of this select component to be filled with ALL values of a particular component in the colum of the second model. Example- Table 1: id name comment Table 2: id comment I do not want to use any relationship (as in has_many, etc.) here because I hope in the future to allow the user to be able to add their own comment if they do not find a comment in the select component that they like. Can this be done without explicity stating SQL in the find_by_sql command. Thanks, Benjamin -- 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 -~----------~----~----~----~------~----~------~--~---
Max Muermann
2006-Sep-19 03:19 UTC
Re: Accessing data in a separate table w/out relationship
On 9/19/06, Benjamin Hecht <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > This question has two parts > > 1) I currently have setup two models and 1 controller. In the view of > the controller I have setup a form with a select form component and > would like the values of this select component to be filled with ALL > values of a particular component in the colum of the second model. > > Example- > > Table 1: id name comment > Table 2: id comment > > I do not want to use any relationship (as in has_many, etc.) here > because I hope in the future to allow the user to be able to add their > own comment if they do not find a comment in the select component that > they like. Can this be done without explicity stating SQL in the > find_by_sql command. > > Thanks, > Benjamin >Acts_as_dropdown may be what you want: http://delynnberry.com/pages/acts_as_dropdown/ Cheers, Max --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Benjamin Hecht
2006-Sep-19 03:57 UTC
Re: Accessing data in a separate table w/out relationship
I''d rather not use a plugin. Are there any work-arounds? -- 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 -~----------~----~----~----~------~----~------~--~---
Max Muermann
2006-Sep-19 04:49 UTC
Re: Accessing data in a separate table w/out relationship
On 9/19/06, Benjamin Hecht <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > I''d rather not use a plugin. Are there any work-arounds? > > --Use <%= collection_select ''model_1_name'', ''comment'', Comment.find(:all), ''id'', ''name'' %> and read up here: http://wiki.rubyonrails.org/rails/pages/HowtoUseFormOptionHelpers Cheers, Max --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Benjamin Hecht
2006-Sep-19 05:00 UTC
Re: Accessing data in a separate table w/out relationship
Max Muermann wrote:> On 9/19/06, Benjamin Hecht <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: >> >> I''d rather not use a plugin. Are there any work-arounds? >> >> -- > > Use > > <%= collection_select ''model_1_name'', ''comment'', Comment.find(:all), > ''id'', ''name'' %> > > and read up here: > > http://wiki.rubyonrails.org/rails/pages/HowtoUseFormOptionHelpers > > Cheers, > MaxThanks -- 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 -~----------~----~----~----~------~----~------~--~---