Hello, i want to insert a select field into my form. The fields of the select-field should come from a database that is created in a different modell in the same project. I don´t need relations simply the content from one field in the table that should populate the select-field. How can i do this? The selected item from the select-field will then be saved amoung other fields in a second database tia for a hint! -- 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Jul 14, 12:20 pm, Einar Kretzler <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hello, > i want to insert a select field into my form. > The fields of the select-field should come from a database that is > created in a different modell in the same project. > I don´t need relations simply the content from one field in the table > that should populate the select-field. > How can i do this? > The selected item from the select-field will then be saved amoung other > fields in a second database > tia for a hint! > -- > Posted viahttp://www.ruby-forum.com/.Hi Einar, If I understand your question correctly, you are looking for the collection_select helper. Here is an example I have in my current project: <%= f.collection_select(:user_id, @users, :id, :name) %> This helper method provides the opportunity to present parameters from an unrelated object to the user for selection. Be sure to create the object in the controller method. Hope this helps. --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks, i know the helper method, but i do not know how to reference to the database.. assume i am in the model "a" in the view "a.new.html.erb" how do i implement the creation of the object in the controller of "a" to access the datas from model "b" So as i am a beginner, there seems to be a lack in the knowledge of ruby... so any help would be useful. tia -- 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 -~----------~----~----~----~------~----~------~--~---
I see. Again, assuming I understand your question, in your controller you have a method "def new". In that method you probably have a statement something like this: @a = a.new You would add a second line: @b = b.find(:all) This will create an object of the b model class, which can then be used in the a/new.html.erb view. Hope this helps. On Jul 14, 1:40 pm, Einar Kretzler <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Thanks, i know the helper method, but i do not know how to reference to > the database.. > assume i am in the model "a" in the view "a.new.html.erb" > how do i implement the creation of the object in the controller of "a" > to access the datas from model "b" > So as i am a beginner, there seems to be a lack in the knowledge of > ruby... > so any help would be useful. > tia > -- > 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---