Lcn Vn wrote:> Hi everyone,
>
> I am a newbee in RoR and i could use some help. I have a select box
> populated by:
>
> <select name = "test_company" id =
"test_company">
> <option selected value=test.company.to_s>Create New </option>
> <%= options_for_select Company.find(:all,
> :conditions => ["name =?", test.company],
> :order => "id asc").collect{|c| [c.external_id, c.name]},
> test.company.to_s %>
> </select>
>
> ... 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.
--
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
-~----------~----~----~----~------~----~------~--~---