Insert select statements from different database

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!

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

On Jul 14, 12:20 pm, Einar K. [email protected]
wrote:


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.

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 K. [email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs