Observe_field and select box

Hi everyone,

I am a newbee in RoR and i could use some help. I have a select box
populated by:

Create New <%= options_for_select Company.find(:all, :conditions => ["name =?", test.company], :order => "id asc").collect{|c| [c.external_id, c.name]}, test.company.to_s %>

… and for the above select box i have an observe field that never
fires up; based on the selection of the first box the second select box
should be populated, and if “Create New” is selected a new record is to
be created.

<%= observe_field(“test_company”,
{:url => {:controller=> ‘/test’,:action =>
‘update_people’},
:update =>“test_person”,
:loading => “Element.show(‘indicator’)”,
:complete => “Element.hide(‘indicator’)”,
:with => "test_company}) %>
If i use
<%= select(:test, :company
,Company.find_all_by_name(test.company.to_s).map{|c| [c.external_id,
c.name]})%>
for my first select box then the observe field works … but i cannot
insert the “Create New” option.

What am I doing wrong?! Any help it would appreciated.

Thank you,

Sincerely,

Lcn Vn wrote:

Hi everyone,

I am a newbee in RoR and i could use some help. I have a select box
populated by:

Create New <%= options_for_select Company.find(:all, :conditions => ["name =?", test.company], :order => "id asc").collect{|c| [c.external_id, c.name]}, test.company.to_s %>

… and for the above select box i have an observe field that never
fires up; based on the selection of the first box the second select box
should be populated, and if “Create New” is selected a new record is to
be created.

<%= observe_field(“test_company”,
{:url => {:controller=> ‘/test’,:action =>
‘update_people’},
:update =>“test_person”,
:loading => “Element.show(‘indicator’)”,
:complete => “Element.hide(‘indicator’)”,
:with => "test_company}) %>
If i use
<%= select(:test, :company
,Company.find_all_by_name(test.company.to_s).map{|c| [c.external_id,
c.name]})%>
for my first select box then the observe field works … but i cannot
insert the “Create New” option.

What am I doing wrong?! Any help it would appreciated.

Thank you,

Sincerely,

Don’t know why the first one doesn’t work, but if you do:

<%= select(:test, :company,
[[‘Create New’,‘Create New’]] +
Company.find_all_by_name(test.company.to_s).map{|c| [c.external_id,
c.name]})%>

You should get the Create New option at the top.

Hope this helps,

Dave.

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